mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-27 19:24:44 +02:00
Cleanup!
This commit is contained in:
@ -113,7 +113,7 @@ public class Combat {
|
||||
if (permInstance.impact(attacker)) {
|
||||
Axes.impact(attacker, target, event);
|
||||
}
|
||||
|
||||
|
||||
if (PPa.getAbilityMode(AbilityType.SKULL_SPLIITER) && permInstance.skullSplitter(attacker)) {
|
||||
applyAbilityAoE(attacker, target, event.getDamage() / 2, plugin, SkillType.AXES);
|
||||
}
|
||||
@ -319,7 +319,7 @@ public class Combat {
|
||||
*/
|
||||
private static void dealDamage(LivingEntity target, int dmg, DamageCause cause) {
|
||||
if (configInstance.getEventCallbackEnabled()) {
|
||||
EntityDamageEvent ede = (EntityDamageEvent) new FakeEntityDamageEvent(target, cause, dmg);
|
||||
EntityDamageEvent ede = new FakeEntityDamageEvent(target, cause, dmg);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(ede);
|
||||
|
||||
if (ede.isCancelled()) {
|
||||
@ -342,7 +342,7 @@ public class Combat {
|
||||
*/
|
||||
private static void dealDamage(LivingEntity target, int dmg, Player attacker) {
|
||||
if (configInstance.getEventCallbackEnabled()) {
|
||||
EntityDamageEvent ede = (EntityDamageByEntityEvent) new FakeEntityDamageByEntityEvent(attacker, target, EntityDamageEvent.DamageCause.ENTITY_ATTACK, dmg);
|
||||
EntityDamageEvent ede = new FakeEntityDamageByEntityEvent(attacker, target, EntityDamageEvent.DamageCause.ENTITY_ATTACK, dmg);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(ede);
|
||||
|
||||
if (ede.isCancelled()) {
|
||||
|
@ -222,23 +222,23 @@ public class Database {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get connection status
|
||||
*
|
||||
*
|
||||
* @return the boolean value for whether or not we are connected
|
||||
*/
|
||||
public static boolean isConnected() {
|
||||
if(conn == null)
|
||||
return false;
|
||||
|
||||
|
||||
try {
|
||||
return conn.isValid(3);
|
||||
} catch (SQLException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Schedules a Sync Delayed Task with the Bukkit Scheduler to attempt reconnection after a minute has elapsed
|
||||
* This will check for a connection being present or not to prevent unneeded reconnection attempts
|
||||
|
@ -11,56 +11,56 @@ public class Hardcore {
|
||||
public static void invokeStatPenalty(Player player) {
|
||||
if(Config.getInstance().getHardcoreDeathStatPenaltyPercentage() <= 0)
|
||||
return;
|
||||
|
||||
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
|
||||
int totalCount = 0;
|
||||
|
||||
|
||||
for(SkillType st : SkillType.values()) {
|
||||
|
||||
|
||||
if(st.equals(SkillType.ALL))
|
||||
continue;
|
||||
|
||||
|
||||
int newValue = (int) (PP.getSkillLevel(st) - (PP.getSkillLevel(st) * (Config.getInstance().getHardcoreDeathStatPenaltyPercentage() * 0.01D)));
|
||||
|
||||
|
||||
if(newValue < 0)
|
||||
newValue = 0;
|
||||
|
||||
|
||||
totalCount+=PP.getSkillLevel(st)-newValue;
|
||||
|
||||
|
||||
PP.modifySkill(st, newValue);
|
||||
}
|
||||
|
||||
|
||||
player.sendMessage(ChatColor.GOLD+"[mcMMO] "+ChatColor.DARK_RED+"You've lost "+ChatColor.BLUE+totalCount+ChatColor.DARK_RED+" from death.");
|
||||
}
|
||||
|
||||
|
||||
public static void invokeVampirism(Player killer, Player defender) {
|
||||
if(Config.getInstance().getHardcoreVampirismStatLeechPercentage() <= 0)
|
||||
return;
|
||||
|
||||
|
||||
PlayerProfile PPk = Users.getProfile(killer);
|
||||
PlayerProfile PPd = Users.getProfile(defender);
|
||||
|
||||
|
||||
int totalCount = 0;
|
||||
|
||||
|
||||
for(SkillType st : SkillType.values()) {
|
||||
if(st.equals(SkillType.ALL))
|
||||
continue;
|
||||
|
||||
|
||||
if(PPd.getSkillLevel(st) <= 0 || PPd.getSkillLevel(st) < (PPk.getSkillLevel(st)/2))
|
||||
continue;
|
||||
|
||||
|
||||
int newValue = (int) (PPd.getSkillLevel(st) * (Config.getInstance().getHardcoreVampirismStatLeechPercentage() * 0.01D));
|
||||
|
||||
|
||||
if(newValue <= 0)
|
||||
newValue = 1;
|
||||
|
||||
|
||||
totalCount+=1;
|
||||
|
||||
|
||||
PPk.modifySkill(st, newValue+PPk.getSkillLevel(st));
|
||||
PPd.modifySkill(st, PPd.getSkillLevel(st)-newValue);
|
||||
}
|
||||
|
||||
|
||||
if(totalCount >= 1) {
|
||||
killer.sendMessage(ChatColor.GOLD+"[mcMMO] "+ChatColor.DARK_AQUA+"You've stolen "+ChatColor.BLUE+totalCount+ChatColor.DARK_AQUA+" levels from that player.");
|
||||
defender.sendMessage(ChatColor.GOLD+"[mcMMO] "+ChatColor.YELLOW+killer.getName()+ChatColor.DARK_RED+" has stolen "+ChatColor.BLUE+totalCount+ChatColor.DARK_RED+" levels from you!");
|
||||
|
@ -74,7 +74,7 @@ public class ItemChecks {
|
||||
*
|
||||
* @param is Item to check
|
||||
* @return true if the item is a shovel, false otherwise
|
||||
*/
|
||||
*/
|
||||
public static boolean isShovel(ItemStack is) {
|
||||
switch (is.getType()) {
|
||||
case DIAMOND_SPADE:
|
||||
|
@ -116,7 +116,7 @@ public class Metrics {
|
||||
* The plugin configuration file
|
||||
*/
|
||||
private final YamlConfiguration configuration;
|
||||
|
||||
|
||||
/**
|
||||
* The plugin configuration file
|
||||
*/
|
||||
@ -225,6 +225,7 @@ public class Metrics {
|
||||
|
||||
private boolean firstPost = true;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
// This has to be synchronized or it can collide with the disable method.
|
||||
|
@ -96,7 +96,7 @@ public class Misc {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Simulate a block break event.
|
||||
*
|
||||
|
@ -9,7 +9,7 @@ import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
|
||||
public class Page {
|
||||
|
||||
|
||||
public static int getTotalPageNumber(String address)
|
||||
{
|
||||
String[] addressSplit = LocaleLoader.getString(address).split("\n");
|
||||
@ -18,24 +18,24 @@ public class Page {
|
||||
else
|
||||
return (addressSplit.length/8)+1;
|
||||
}
|
||||
|
||||
|
||||
public static ArrayList<String> grabPageContents(String header, String address, int pagenum)
|
||||
{
|
||||
int pageIndexStart = 0;
|
||||
|
||||
|
||||
//Determine what string to start at
|
||||
if(pagenum > 1)
|
||||
{
|
||||
pageIndexStart = 8*(pagenum-1);
|
||||
}
|
||||
|
||||
|
||||
ArrayList<String> allStrings = new ArrayList<String>();
|
||||
String split[] = LocaleLoader.getString(address).split("\n");
|
||||
|
||||
|
||||
allStrings.add(ChatColor.GOLD+"-="+ChatColor.GREEN+header+ChatColor.GOLD+"=-"); //So stylish
|
||||
|
||||
|
||||
//Add targeted strings
|
||||
|
||||
|
||||
while(allStrings.size() < 9)
|
||||
{
|
||||
if(pageIndexStart+allStrings.size() > split.length)
|
||||
@ -43,11 +43,11 @@ public class Page {
|
||||
else
|
||||
allStrings.add(split[pageIndexStart+allStrings.size()-1]);
|
||||
}
|
||||
|
||||
|
||||
allStrings.add("Page "+pagenum+" of "+getTotalPageNumber(address));
|
||||
return allStrings;
|
||||
}
|
||||
|
||||
|
||||
public static void clearChat(Player player)
|
||||
{
|
||||
for(int x = 0; x < 20; x++)
|
||||
@ -55,7 +55,7 @@ public class Page {
|
||||
player.sendMessage("");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void grabGuidePageForSkill(SkillType skilltype, Player player, String[] args)
|
||||
{
|
||||
String capitalized = Misc.getCapitalized(skilltype.toString());
|
||||
@ -64,9 +64,9 @@ public class Page {
|
||||
{
|
||||
if(args[0].equals("?"))
|
||||
{
|
||||
|
||||
|
||||
String address = "Guides."+capitalized;
|
||||
|
||||
|
||||
if(args.length > 1 && Misc.isInt(args[1]) && Misc.getInt(args[1]) <= Page.getTotalPageNumber(address))
|
||||
{
|
||||
Page.clearChat(player);
|
||||
@ -82,7 +82,7 @@ public class Page {
|
||||
player.sendMessage(target);
|
||||
}
|
||||
}
|
||||
else if(args.length > 1 && Misc.getInt(args[1]) > Page.getTotalPageNumber(address))
|
||||
else if(args.length > 1 && Misc.getInt(args[1]) > Page.getTotalPageNumber(address))
|
||||
{
|
||||
player.sendMessage("That page doesn't exist, there are only "+Page.getTotalPageNumber(address)+" total pages"); //TODO: Needs more locale.
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ public class Users {
|
||||
* Load users.
|
||||
*/
|
||||
public static void loadUsers() {
|
||||
|
||||
|
||||
|
||||
new File(plugin.flatFileDirectory).mkdir();
|
||||
new File(plugin.leaderboardDirectory).mkdir();
|
||||
|
@ -18,6 +18,7 @@ import com.gmail.nossr50.mcMMO;
|
||||
public class HashChunkletManager implements ChunkletManager {
|
||||
private HashMap<String, ChunkletStore> store = new HashMap<String, ChunkletStore>();
|
||||
|
||||
@Override
|
||||
public void chunkLoaded(int cx, int cz, World world) {
|
||||
File dataDir = new File(world.getWorldFolder(), "mcmmo_data");
|
||||
File cxDir = new File(dataDir, "" + cx);
|
||||
@ -38,6 +39,7 @@ public class HashChunkletManager implements ChunkletManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void chunkUnloaded(int cx, int cz, World world) {
|
||||
File dataDir = new File(world.getWorldFolder(), "mcmmo_data");
|
||||
|
||||
@ -56,6 +58,7 @@ public class HashChunkletManager implements ChunkletManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveWorld(World world) {
|
||||
String worldName = world.getName();
|
||||
File dataDir = new File(world.getWorldFolder(), "mcmmo_data");
|
||||
@ -74,6 +77,7 @@ public class HashChunkletManager implements ChunkletManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unloadWorld(World world) {
|
||||
saveWorld(world);
|
||||
|
||||
@ -87,12 +91,14 @@ public class HashChunkletManager implements ChunkletManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveAll() {
|
||||
for(World world : Bukkit.getWorlds()) {
|
||||
saveWorld(world);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unloadAll() {
|
||||
saveAll();
|
||||
for(World world : Bukkit.getWorlds()) {
|
||||
@ -100,6 +106,7 @@ public class HashChunkletManager implements ChunkletManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTrue(int x, int y, int z, World world) {
|
||||
int cx = x / 16;
|
||||
int cz = z / 16;
|
||||
@ -114,10 +121,12 @@ public class HashChunkletManager implements ChunkletManager {
|
||||
return check.isTrue(ix, iy, iz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTrue(Block block) {
|
||||
return isTrue(block.getX(), block.getY(), block.getZ(), block.getWorld());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTrue(int x, int y, int z, World world) {
|
||||
int cx = x / 16;
|
||||
int cz = z / 16;
|
||||
@ -137,10 +146,12 @@ public class HashChunkletManager implements ChunkletManager {
|
||||
cStore.setTrue(ix, iy, iz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTrue(Block block) {
|
||||
setTrue(block.getX(), block.getY(), block.getZ(), block.getWorld());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFalse(int x, int y, int z, World world) {
|
||||
int cx = x / 16;
|
||||
int cz = z / 16;
|
||||
@ -159,10 +170,12 @@ public class HashChunkletManager implements ChunkletManager {
|
||||
cStore.setFalse(ix, iy, iz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFalse(Block block) {
|
||||
setFalse(block.getX(), block.getY(), block.getZ(), block.getWorld());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanUp() {
|
||||
for(String key : store.keySet()) {
|
||||
if(store.get(key).isEmpty()) {
|
||||
|
@ -6,18 +6,22 @@ public class PrimitiveChunkletStore implements ChunkletStore {
|
||||
/** X, Z, Y */
|
||||
private boolean[][][] store = new boolean[16][16][64];
|
||||
|
||||
@Override
|
||||
public boolean isTrue(int x, int y, int z) {
|
||||
return store[x][z][y];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTrue(int x, int y, int z) {
|
||||
store[x][z][y] = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFalse(int x, int y, int z) {
|
||||
store[x][z][y] = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
for(int x = 0; x < 16; x++) {
|
||||
for(int z = 0; z < 16; z++) {
|
||||
|
Reference in New Issue
Block a user