本文整理汇总了Java中com.dsh105.echopet.compat.api.util.Logger类的典型用法代码示例。如果您正苦于以下问题:Java Logger类的具体用法?Java Logger怎么用?Java Logger使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Logger类属于com.dsh105.echopet.compat.api.util包,在下文中一共展示了Logger类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setPathfinding
import com.dsh105.echopet.compat.api.util.Logger; //导入依赖的package包/类
public void setPathfinding() {
try {
NMSEntityUtil.clearGoals(this);
this.petGoalSelector = new PetGoalSelector();
petGoalSelector.addGoal(new PetGoalFloat(this), 0);
petGoalSelector.addGoal(new PetGoalFollowOwner(this, this.getSizeCategory().getStartWalk(getPet().getPetType()), this.getSizeCategory().getStopWalk(getPet().getPetType()), this.getSizeCategory().getTeleport(getPet().getPetType())), 1);
petGoalSelector.addGoal(new PetGoalLookAtPlayer(this, EntityHuman.class), 2);
} catch (Exception e) {
e.printStackTrace();
Logger.log(Logger.LogLevel.WARNING, "Could not add PetGoals to Pet AI.", e, true);
}
}
示例2: clearFromDatabase
import com.dsh105.echopet.compat.api.util.Logger; //导入依赖的package包/类
@Override
public void clearFromDatabase(String playerIdent) {
if (EchoPet.getOptions().useSql()) {
Connection con = null;
PreparedStatement ps = null;
if (EchoPet.getPlugin().getDbPool() != null) {
try {
con = EchoPet.getPlugin().getDbPool().getConnection();
ps = con.prepareStatement("DELETE FROM " + TableMigrationUtil.LATEST_TABLE + " WHERE OwnerName = ?;");
ps.setString(1, String.valueOf(playerIdent));
ps.executeUpdate();
} catch (SQLException e) {
Logger.log(Logger.LogLevel.SEVERE, "Failed to retrieve Pet data for " + playerIdent + " in MySQL Database", e, true);
} finally {
try {
if (ps != null) {
ps.close();
}
if (con != null) {
con.close();
}
} catch (SQLException ignored) {
}
}
}
}
}
示例3: clearRiderFromDatabase
import com.dsh105.echopet.compat.api.util.Logger; //导入依赖的package包/类
@Override
public void clearRiderFromDatabase(String playerIdent) {
if (EchoPet.getOptions().useSql()) {
Connection con = null;
PreparedStatement ps = null;
if (EchoPet.getPlugin().getDbPool() != null) {
try {
con = EchoPet.getPlugin().getDbPool().getConnection();
ps = con.prepareStatement("UPDATE " + TableMigrationUtil.LATEST_TABLE + " SET RiderData = ? WHERE OwnerName = ?;");
ps.setLong(1, SQLUtil.serializePetData(Arrays.asList(PetData.values())));
ps.setString(2, String.valueOf(playerIdent));
ps.executeUpdate();
} catch (SQLException e) {
Logger.log(Logger.LogLevel.SEVERE, "Failed to retrieve Pet data for " + playerIdent + " in MySQL Database", e, true);
} finally {
try {
if (ps != null) {
ps.close();
}
if (con != null) {
con.close();
}
} catch (SQLException ignored) {
}
}
}
}
}
示例4: setPathfinding
import com.dsh105.echopet.compat.api.util.Logger; //导入依赖的package包/类
public void setPathfinding(){
try{
NMSEntityUtil.clearGoals(this);
petGoalSelector = new PetGoalSelector();
petGoalSelector.addGoal(new PetGoalFloat(this), 0);
petGoalSelector.addGoal(new PetGoalFollowOwner(this, this.getSizeCategory().getStartWalk(getPet().getPetType()), this.getSizeCategory().getStopWalk(getPet().getPetType()), this.getSizeCategory().getTeleport(getPet().getPetType())), 1);
petGoalSelector.addGoal(new PetGoalLookAtPlayer(this, EntityHuman.class), 2);
}catch(Exception e){
e.printStackTrace();
Logger.log(Logger.LogLevel.WARNING, "Could not add PetGoals to Pet AI.", e, true);
}
}
示例5: loadRiderFromFile
import com.dsh105.echopet.compat.api.util.Logger; //导入依赖的package包/类
@Override
public void loadRiderFromFile(String type, IPet pet) {
String path = type + "." + pet.getOwnerUUID();
if (EchoPet.getConfig(EchoPet.ConfigType.DATA).get(path + ".rider.type") != null) {
ArrayList<PetData> riderData = new ArrayList<>();
PetType riderPetType = PetType.fromDataString(EchoPet.getConfig(EchoPet.ConfigType.DATA).getString(path + ".rider.type"), riderData);
String riderName = EchoPet.getConfig(EchoPet.ConfigType.DATA).getString(path + ".rider.name");
if (Strings.isNullOrEmpty(riderName)) {
riderName = riderPetType.getDefaultName(pet.getNameOfOwner());
}
if (EchoPet.getOptions().allowRidersFor(pet.getPetType())) {
IPet rider = pet.createRider(riderPetType, true);
if (rider != null && rider.isSpawned()) {
rider.setPetName(riderName);
ConfigurationSection mcs = EchoPet.getConfig(EchoPet.ConfigType.DATA).getConfigurationSection(path + ".rider.data");
if (mcs != null) {
for (String key : mcs.getKeys(false)) {
if (GeneralUtil.isEnumType(PetData.class, key.toUpperCase())) {
PetData pd = PetData.valueOf(key.toUpperCase());
riderData.add(pd);
} else {
Logger.log(Logger.LogLevel.WARNING, "Error whilst loading data Pet Rider Save Data for " + pet.getNameOfOwner() + ". Unknown enum type: " + key + ".", true);
}
}
}
if (!riderData.isEmpty()) {
setData(pet, riderData.toArray(new PetData[riderData.size()]), true);
}
}
}
}
}
示例6: setPathfinding
import com.dsh105.echopet.compat.api.util.Logger; //导入依赖的package包/类
public void setPathfinding() {
try {
petGoalSelector = new PetGoalSelector();
getEntity().clearGoals();
petGoalSelector.addGoal(new PetGoalFloat(this), 0);
petGoalSelector.addGoal(new PetGoalFollowOwner(this, this.getSizeCategory().getStartWalk(getPet().getPetType()), this.getSizeCategory().getStopWalk(getPet().getPetType()), this.getSizeCategory().getTeleport(getPet().getPetType())), 1);
petGoalSelector.addGoal(new PetGoalLookAtPlayer(this), 2);
} catch (Exception e) {
Logger.log(Logger.LogLevel.WARNING, "Could not add PetGoals to Pet AI.", e, true);
}
}
示例7: saveToDatabase
import com.dsh105.echopet.compat.api.util.Logger; //导入依赖的package包/类
@Override
public void saveToDatabase(String playerIdent, PetType petType, String petName, List<PetData> petData, boolean isRider) {
if (EchoPet.getOptions().useSql()) {
Connection con = null;
PreparedStatement ps = null;
if (EchoPet.getPlugin().getDbPool() != null) {
try {
con = EchoPet.getPlugin().getDbPool().getConnection();
// Delete any existing info
if (!isRider) {
this.clearFromDatabase(playerIdent);
}
// Deal with the pet metadata first
// This tends to be more problematic, so by shoving it out of the way, we can get the pet data saved.
if (isRider) {
ps = con.prepareStatement("UPDATE " + TableMigrationUtil.LATEST_TABLE + " SET RiderPetType = ?, RiderPetName = ?, RiderPetData = ? WHERE OwnerName = ?");
ps.setString(1, petType.toString());
ps.setString(2, petName);
ps.setLong(3, SQLUtil.serializePetData(petData));
ps.setString(4, String.valueOf(playerIdent));
ps.executeUpdate();
} else {
ps = con.prepareStatement("INSERT INTO " + TableMigrationUtil.LATEST_TABLE + " (OwnerName, PetType, PetName, PetData) VALUES (?, ?, ?, ?)");
ps.setString(1, String.valueOf(playerIdent));
ps.setString(2, petType.toString());
ps.setString(3, petName);
ps.setLong(4, SQLUtil.serializePetData(petData));
ps.executeUpdate();
}
} catch (SQLException e) {
Logger.log(Logger.LogLevel.SEVERE, "Failed to save Pet data for " + playerIdent + " to MySQL Database", e, true);
} finally {
try {
if (ps != null) {
ps.close();
}
if (con != null) {
con.close();
}
} catch (SQLException ignored) {
}
}
}
}
}
示例8: createPetFromFile
import com.dsh105.echopet.compat.api.util.Logger; //导入依赖的package包/类
@Override
public IPet createPetFromFile(String type, Player p) {
if (EchoPet.getOptions().getConfig().getBoolean("loadSavedPets", true)) {
String path = type + "." + UUIDMigration.getIdentificationFor(p);
if (EchoPet.getConfig(EchoPet.ConfigType.DATA).get(path) != null) {
ArrayList<PetData> data = new ArrayList<>();
PetType petType = PetType.fromDataString(EchoPet.getConfig(EchoPet.ConfigType.DATA).getString(path + ".pet.type"), data);
String name = EchoPet.getConfig(EchoPet.ConfigType.DATA).getString(path + ".pet.name");
if (Strings.isNullOrEmpty(name)) {
name = petType.getDefaultName(p.getName());
}
if (!EchoPet.getOptions().allowPetType(petType)) {
return null;
}
IPet pi = this.createPet(p, petType, true);
if (pi == null) {
return null;
}
//Pet pi = petType.getNewPetInstance(p, petType);
//Pet pi = new Pet(p, petType);
pi.setPetName(name);
ConfigurationSection cs = EchoPet.getConfig(EchoPet.ConfigType.DATA).getConfigurationSection(path + ".pet.data");
if (cs != null) {
for (String key : cs.getKeys(false)) {
if (GeneralUtil.isEnumType(PetData.class, key.toUpperCase())) {
PetData pd = PetData.valueOf(key.toUpperCase());
data.add(pd);
} else {
Logger.log(Logger.LogLevel.WARNING, "Error whilst loading data Pet Save Data for " + pi.getNameOfOwner() + ". Unknown enum type: " + key + ".", true);
}
}
}
if (!data.isEmpty()) {
setData(pi, data.toArray(new PetData[data.size()]), true);
}
this.loadRiderFromFile(type, pi);
forceAllValidData(pi);
return pi;
}
}
return null;
}
示例9: prepareSqlDatabase
import com.dsh105.echopet.compat.api.util.Logger; //导入依赖的package包/类
private void prepareSqlDatabase() {
String host = mainConfig.getString("sql.host", "localhost");
int port = mainConfig.getInt("sql.port", 3306);
String db = mainConfig.getString("sql.database", "EchoPet");
String user = mainConfig.getString("sql.username", "none");
String pass = mainConfig.getString("sql.password", "none");
HikariConfig config = new HikariConfig();
config.setJdbcUrl("jdbc:mysql://" + host + ":" + port + "/" + db);
config.setUsername(user);
config.setPassword(pass);
dbPool = new HikariDataSource(config);
Connection connection = null;
Statement statement = null;
try {
connection = dbPool.getConnection();
statement = connection.createStatement();
statement.executeUpdate("CREATE TABLE IF NOT EXISTS EchoPet_version3 (" +
"OwnerName varchar(36)," +
"PetType varchar(255)," +
"PetName varchar(255)," +
"PetData BIGINT," +
"RiderPetType varchar(255)," +
"RiderPetName varchar(255), " +
"RiderPetData BIGINT," +
"PRIMARY KEY (OwnerName)" +
");");
// Convert previous database versions
TableMigrationUtil.migrateTables();
} catch (SQLException e) {
Logger.log(Logger.LogLevel.SEVERE, "Table generation failed [MySQL DataBase: " + db + "].", e, true);
} finally {
try {
if (statement != null) {
statement.close();
}
if (connection != null) {
connection.close();
}
} catch (SQLException ignored) {
}
}
// Make sure to convert those UUIDs!
}