mirror of
https://github.com/songoda/SongodaCore.git
synced 2025-02-03 05:01:27 +01:00
Merge remote-tracking branch 'origin/development' into development
This commit is contained in:
commit
6951a7f4ad
@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>SongodaCore-Modules</artifactId>
|
||||
<version>2.5.8</version>
|
||||
<version>2.5.9</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -1237,7 +1237,7 @@ public enum CompatibleSound {
|
||||
}
|
||||
}
|
||||
if (DEBUG && find == null) {
|
||||
System.out.println("Sound for " + name() + " Not found!");
|
||||
System.err.println("Sound for " + name() + " not found!");
|
||||
}
|
||||
sound = find;
|
||||
compatibilityMode = find == null;
|
||||
@ -1253,7 +1253,7 @@ public enum CompatibleSound {
|
||||
sound = Sound.valueOf(name());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("ERROR loading " + name());
|
||||
System.err.println("ERROR loading " + name());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -1268,9 +1268,9 @@ public enum CompatibleSound {
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("ERROR loading " + name());
|
||||
System.err.println("ERROR loading " + name());
|
||||
for (Version v : versions) {
|
||||
System.out.println(v.version + " - " + v.sound);
|
||||
System.err.println(v.version + " - " + v.sound);
|
||||
}
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -1303,9 +1303,9 @@ public enum CompatibleSound {
|
||||
compatibilityMode = false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("ERROR loading " + name() + " (" + minVersion);
|
||||
System.err.println("ERROR loading " + name() + " (" + minVersion);
|
||||
for (Version v : versions) {
|
||||
System.out.println(v.version + " - " + v.sound);
|
||||
System.err.println(v.version + " - " + v.sound);
|
||||
}
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>SongodaCore-Modules</artifactId>
|
||||
<version>2.5.8</version>
|
||||
<version>2.5.9</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -39,10 +39,10 @@ import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class SongodaCore {
|
||||
|
||||
private final static String prefix = "[SongodaCore]";
|
||||
private final static Logger logger = Logger.getLogger("SongodaCore");
|
||||
|
||||
/**
|
||||
* Whenever we make a major change to the core GUI, updater,
|
||||
@ -53,7 +53,7 @@ public class SongodaCore {
|
||||
/**
|
||||
* This has been added as of Rev 6
|
||||
*/
|
||||
private final static String coreVersion = "2.5.8";
|
||||
private final static String coreVersion = "2.5.9";
|
||||
|
||||
/**
|
||||
* This is specific to the website api
|
||||
@ -197,7 +197,7 @@ public class SongodaCore {
|
||||
private ArrayList<BukkitTask> tasks = new ArrayList();
|
||||
|
||||
private void register(JavaPlugin plugin, int pluginID, String icon, String libraryVersion) {
|
||||
System.out.println(getPrefix() + "Hooked " + plugin.getName() + ".");
|
||||
logger.info(getPrefix() + "Hooked " + plugin.getName() + ".");
|
||||
PluginInfo info = new PluginInfo(plugin, pluginID, icon, libraryVersion);
|
||||
// don't forget to check for language pack updates ;)
|
||||
info.addModule(new LocaleModule());
|
||||
@ -240,9 +240,9 @@ public class SongodaCore {
|
||||
}
|
||||
} catch (IOException e) {
|
||||
final String er = e.getMessage();
|
||||
System.out.println("Connection with Songoda servers failed: " + (er.contains("URL") ? er.substring(0, er.indexOf("URL") + 3) : er));
|
||||
logger.log(Level.FINE, "Connection with Songoda servers failed: " + (er.contains("URL") ? er.substring(0, er.indexOf("URL") + 3) : er));
|
||||
} catch (ParseException e) {
|
||||
System.out.println("Failed to parse json for " + plugin.getJavaPlugin().getName() + " update check");
|
||||
logger.log(Level.FINE, "Failed to parse json for " + plugin.getJavaPlugin().getName() + " update check");
|
||||
}
|
||||
}
|
||||
|
||||
@ -263,7 +263,11 @@ public class SongodaCore {
|
||||
}
|
||||
|
||||
public static String getPrefix() {
|
||||
return prefix + " ";
|
||||
return "[SongodaCore] ";
|
||||
}
|
||||
|
||||
public static Logger getLogger() {
|
||||
return logger;
|
||||
}
|
||||
|
||||
public static boolean isRegistered(String plugin) {
|
||||
|
@ -1,10 +1,12 @@
|
||||
package com.songoda.core.configuration;
|
||||
|
||||
import com.songoda.core.SongodaCore;
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class ConfigSetting {
|
||||
|
||||
@ -111,7 +113,7 @@ public class ConfigSetting {
|
||||
CompatibleMaterial mat = CompatibleMaterial.getMaterial(config.getString(key));
|
||||
|
||||
if (mat == null) {
|
||||
System.out.println(String.format("Config value \"%s\" has an invalid material name: \"%s\"", key, val));
|
||||
SongodaCore.getLogger().log(Level.WARNING, String.format("Config value \"%s\" has an invalid material name: \"%s\"", key, val));
|
||||
}
|
||||
|
||||
return mat != null ? mat : CompatibleMaterial.STONE;
|
||||
@ -124,7 +126,7 @@ public class ConfigSetting {
|
||||
CompatibleMaterial mat = val != null ? CompatibleMaterial.getMaterial(val) : null;
|
||||
|
||||
if (mat == null) {
|
||||
System.out.println(String.format("Config value \"%s\" has an invalid material name: \"%s\"", key, val));
|
||||
SongodaCore.getLogger().log(Level.WARNING, String.format("Config value \"%s\" has an invalid material name: \"%s\"", key, val));
|
||||
}
|
||||
|
||||
return mat != null ? mat : def;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.songoda.core.database;
|
||||
|
||||
import com.songoda.core.SongodaCore;
|
||||
import com.zaxxer.hikari.HikariConfig;
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
@ -16,7 +17,7 @@ public class MySQLConnector implements DatabaseConnector {
|
||||
public MySQLConnector(Plugin plugin, String hostname, int port, String database, String username, String password, boolean useSSL) {
|
||||
this.plugin = plugin;
|
||||
|
||||
System.out.println("connecting to " + hostname + " : " + port);
|
||||
plugin.getLogger().info("connecting to " + hostname + " : " + port);
|
||||
|
||||
HikariConfig config = new HikariConfig();
|
||||
config.setJdbcUrl("jdbc:mysql://" + hostname + ":" + port + "/" + database + "?useSSL=" + useSSL);
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.songoda.core.utils;
|
||||
|
||||
import com.songoda.core.SongodaCore;
|
||||
import com.songoda.core.compatibility.ClassMapping;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import org.bukkit.Effect;
|
||||
@ -137,7 +138,6 @@ public class BlockUtilsModern {
|
||||
Object mblock = nmsBlockData_getBlock.invoke(craftBlock_getNMS.invoke(cblock));
|
||||
Object mpos = craftBlock_getPostition.invoke(cblock);
|
||||
|
||||
//System.out.println(mblock.getClass());
|
||||
// now for testing stuff
|
||||
if (clazzLeverBlock.isAssignableFrom(mblock.getClass())) {
|
||||
final Object mstate = craftBlockData_getState.invoke(block.getBlockData());
|
||||
@ -148,7 +148,7 @@ public class BlockUtilsModern {
|
||||
} else if (clazzPressurePlateBlock.isAssignableFrom(mblock.getClass())) {
|
||||
nmsPlate_updateNeighbours.invoke(mblock, mworld, mpos);
|
||||
} else {
|
||||
System.out.println("Unknown redstone: " + mblock.getClass().getName());
|
||||
SongodaCore.getLogger().warning("Unknown redstone: " + mblock.getClass().getName());
|
||||
}
|
||||
//
|
||||
// if(mblock instanceof net.minecraft.server.v1_15_R1.BlockLever) {
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.songoda.core.utils;
|
||||
|
||||
import com.songoda.core.SongodaCore;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.annotation.Annotation;
|
||||
@ -23,6 +25,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.logging.Level;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
@ -152,7 +155,7 @@ public class ReflectionUtils {
|
||||
Class<?> loadedClazz = Class.forName(name.substring(0, name.lastIndexOf('.')).replace('/', '.'));
|
||||
packageClasses.add(loadedClazz);
|
||||
} catch (ClassNotFoundException e1) {
|
||||
System.err.println("class not found: " + e1.getMessage());
|
||||
SongodaCore.getLogger().log(Level.FINE, "class not found: " + e1.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -179,7 +182,7 @@ public class ReflectionUtils {
|
||||
|
||||
packageClasses.add(loadedClazz);
|
||||
} catch (ClassNotFoundException e) {
|
||||
System.err.println("class not found: " + e.getMessage());
|
||||
SongodaCore.getLogger().log(Level.FINE, "class not found: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
return super.visitFile(file, attrs);
|
||||
|
@ -5,6 +5,7 @@ import com.songoda.core.compatibility.CompatibleSound;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.core.nms.NmsManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerItemBreakEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -26,16 +27,23 @@ public class SItemStack {
|
||||
this.sItem = NmsManager.getWorld().getItemStack(item);
|
||||
}
|
||||
|
||||
public ItemStack addDamage(Player player, int damage) {
|
||||
return addDamage(player, damage, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Damage the selected item
|
||||
*
|
||||
* @param player the player who's item you want to damage
|
||||
* @param damage the amount of damage to apply to the item
|
||||
*/
|
||||
public ItemStack addDamage(Player player, int damage) {
|
||||
public ItemStack addDamage(Player player, int damage, boolean respectVanillaUnbreakingEnchantments) {
|
||||
if (item == null)
|
||||
return null;
|
||||
|
||||
if (item.getItemMeta() == null)
|
||||
return item;
|
||||
|
||||
int maxDurability = item.getType().getMaxDurability();
|
||||
int durability;
|
||||
|
||||
@ -48,6 +56,11 @@ public class SItemStack {
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta instanceof Damageable) {
|
||||
Damageable damageable = ((Damageable) meta);
|
||||
|
||||
if (respectVanillaUnbreakingEnchantments) {
|
||||
damage = shouldApplyDamage(meta.getEnchantLevel(Enchantment.DURABILITY), damage);
|
||||
}
|
||||
|
||||
damageable.setDamage(((Damageable) meta).getDamage() + damage);
|
||||
item.setItemMeta(meta);
|
||||
durability = damageable.getDamage();
|
||||
@ -55,6 +68,10 @@ public class SItemStack {
|
||||
return item;
|
||||
}
|
||||
} else {
|
||||
if (respectVanillaUnbreakingEnchantments) {
|
||||
damage = shouldApplyDamage(item.getEnchantmentLevel(Enchantment.DURABILITY), damage);
|
||||
}
|
||||
|
||||
item.setDurability((short) Math.max(0, item.getDurability() + damage));
|
||||
durability = item.getDurability();
|
||||
}
|
||||
@ -78,4 +95,22 @@ public class SItemStack {
|
||||
public ItemStack getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
private static int shouldApplyDamage(int unbreakingEnchantLevel, int damageAmount) {
|
||||
int result = 0;
|
||||
|
||||
for (int i = 0; i < damageAmount; ++i) {
|
||||
if (shouldApplyDamage(unbreakingEnchantLevel)) {
|
||||
++result;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static boolean shouldApplyDamage(int unbreakingEnchantLevel) {
|
||||
if (unbreakingEnchantLevel <= 0) return true;
|
||||
|
||||
return Math.random() <= 1.0 / (unbreakingEnchantLevel + 1);
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>SongodaCore-Modules</artifactId>
|
||||
<version>2.5.8</version>
|
||||
<version>2.5.9</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>SongodaCore-Modules</artifactId>
|
||||
<version>2.5.8</version>
|
||||
<version>2.5.9</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>SongodaCore-Modules</artifactId>
|
||||
<version>2.5.8</version>
|
||||
<version>2.5.9</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>SongodaCore-Modules</artifactId>
|
||||
<version>2.5.8</version>
|
||||
<version>2.5.9</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>SongodaCore-Modules</artifactId>
|
||||
<version>2.5.8</version>
|
||||
<version>2.5.9</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>SongodaCore-Modules</artifactId>
|
||||
<version>2.5.8</version>
|
||||
<version>2.5.9</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>SongodaCore-Modules</artifactId>
|
||||
<version>2.5.8</version>
|
||||
<version>2.5.9</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>SongodaCore-Modules</artifactId>
|
||||
<version>2.5.8</version>
|
||||
<version>2.5.9</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>SongodaCore-Modules</artifactId>
|
||||
<version>2.5.8</version>
|
||||
<version>2.5.9</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>SongodaCore-Modules</artifactId>
|
||||
<version>2.5.8</version>
|
||||
<version>2.5.9</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>SongodaCore-Modules</artifactId>
|
||||
<version>2.5.8</version>
|
||||
<version>2.5.9</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>SongodaCore-Modules</artifactId>
|
||||
<version>2.5.8</version>
|
||||
<version>2.5.9</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>SongodaCore-Modules</artifactId>
|
||||
<version>2.5.8</version>
|
||||
<version>2.5.9</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>SongodaCore-Modules</artifactId>
|
||||
<version>2.5.8</version>
|
||||
<version>2.5.9</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>SongodaCore-Modules</artifactId>
|
||||
<version>2.5.8</version>
|
||||
<version>2.5.9</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>SongodaCore-Modules</artifactId>
|
||||
<version>2.5.8</version>
|
||||
<version>2.5.9</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>SongodaCore-Modules</artifactId>
|
||||
<version>2.5.8</version>
|
||||
<version>2.5.9</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user