mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 15:16:45 +01:00
Protect our managers.
This commit is contained in:
parent
a2fefd6fb6
commit
98dc7b853a
@ -23,10 +23,10 @@ public class McpurgeCommand implements TabExecutor {
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
mcMMO.databaseManager.purgePowerlessUsers();
|
||||
mcMMO.getDatabaseManager().purgePowerlessUsers();
|
||||
|
||||
if (Config.getInstance().getOldUsersCutoff() != -1) {
|
||||
mcMMO.databaseManager.purgeOldUsers();
|
||||
mcMMO.getDatabaseManager().purgeOldUsers();
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcpurge.Success"));
|
||||
|
@ -32,7 +32,7 @@ public class McremoveCommand implements TabExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (mcMMO.databaseManager.removeUser(args[0])) {
|
||||
if (mcMMO.getDatabaseManager().removeUser(args[0])) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcremove.Success", args[0]));
|
||||
}
|
||||
else {
|
||||
|
@ -41,10 +41,10 @@ public class RepairCommand extends SkillCommand {
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
// We're using pickaxes here, not the best but it works
|
||||
Repairable diamondRepairable = mcMMO.repairableManager.getRepairable(Material.DIAMOND_PICKAXE.getId());
|
||||
Repairable goldRepairable = mcMMO.repairableManager.getRepairable(Material.GOLD_PICKAXE.getId());
|
||||
Repairable ironRepairable = mcMMO.repairableManager.getRepairable(Material.IRON_PICKAXE.getId());
|
||||
Repairable stoneRepairable = mcMMO.repairableManager.getRepairable(Material.STONE_PICKAXE.getId());
|
||||
Repairable diamondRepairable = mcMMO.getRepairableManager().getRepairable(Material.DIAMOND_PICKAXE.getId());
|
||||
Repairable goldRepairable = mcMMO.getRepairableManager().getRepairable(Material.GOLD_PICKAXE.getId());
|
||||
Repairable ironRepairable = mcMMO.getRepairableManager().getRepairable(Material.IRON_PICKAXE.getId());
|
||||
Repairable stoneRepairable = mcMMO.getRepairableManager().getRepairable(Material.STONE_PICKAXE.getId());
|
||||
|
||||
// TODO: This isn't really accurate - if they don't have pickaxes loaded it doesn't always mean the repair level is 0
|
||||
diamondLevel = (diamondRepairable == null) ? 0 : diamondRepairable.getMinimumLevel();
|
||||
|
@ -63,17 +63,17 @@ public class BlockListener implements Listener {
|
||||
Block futureEmptyBlock = event.getBlock().getRelative(direction); // Block that would be air after piston is finished
|
||||
|
||||
for (Block b : blocks) {
|
||||
if (BlockUtils.shouldBeWatched(b.getState()) && mcMMO.placeStore.isTrue(b)) {
|
||||
if (BlockUtils.shouldBeWatched(b.getState()) && mcMMO.getPlaceStore().isTrue(b)) {
|
||||
b.getRelative(direction).setMetadata(mcMMO.blockMetadataKey, mcMMO.metadataValue);
|
||||
if (b.equals(futureEmptyBlock)) {
|
||||
mcMMO.placeStore.setFalse(b);
|
||||
mcMMO.getPlaceStore().setFalse(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (Block b : blocks) {
|
||||
if (b.getRelative(direction).hasMetadata(mcMMO.blockMetadataKey)) {
|
||||
mcMMO.placeStore.setTrue(b.getRelative(direction));
|
||||
mcMMO.getPlaceStore().setTrue(b.getRelative(direction));
|
||||
b.getRelative(direction).removeMetadata(mcMMO.blockMetadataKey, plugin);
|
||||
}
|
||||
}
|
||||
@ -110,7 +110,7 @@ public class BlockListener implements Listener {
|
||||
|
||||
/* Check if the blocks placed should be monitored so they do not give out XP in the future */
|
||||
if (BlockUtils.shouldBeWatched(blockState)) {
|
||||
mcMMO.placeStore.setTrue(blockState);
|
||||
mcMMO.getPlaceStore().setTrue(blockState);
|
||||
}
|
||||
|
||||
if (Repair.anvilMessagesEnabled && (blockId == Repair.repairAnvilId || blockId == Repair.salvageAnvilId)) {
|
||||
@ -163,13 +163,13 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
|
||||
/* MINING */
|
||||
else if (BlockUtils.affectedBySuperBreaker(blockState) && ItemUtils.isPickaxe(heldItem) && Permissions.skillEnabled(player, SkillType.MINING) && !mcMMO.placeStore.isTrue(blockState)) {
|
||||
else if (BlockUtils.affectedBySuperBreaker(blockState) && ItemUtils.isPickaxe(heldItem) && Permissions.skillEnabled(player, SkillType.MINING) && !mcMMO.getPlaceStore().isTrue(blockState)) {
|
||||
MiningManager miningManager = mcMMOPlayer.getMiningManager();
|
||||
miningManager.miningBlockCheck(blockState);
|
||||
}
|
||||
|
||||
/* WOOD CUTTING */
|
||||
else if (BlockUtils.isLog(blockState) && Permissions.skillEnabled(player, SkillType.WOODCUTTING) && !mcMMO.placeStore.isTrue(blockState)) {
|
||||
else if (BlockUtils.isLog(blockState) && Permissions.skillEnabled(player, SkillType.WOODCUTTING) && !mcMMO.getPlaceStore().isTrue(blockState)) {
|
||||
WoodcuttingManager woodcuttingManager = mcMMOPlayer.getWoodcuttingManager();
|
||||
|
||||
if (woodcuttingManager.canUseTreeFeller(heldItem)) {
|
||||
@ -181,7 +181,7 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
|
||||
/* EXCAVATION */
|
||||
else if (BlockUtils.affectedByGigaDrillBreaker(blockState) && ItemUtils.isShovel(heldItem) && Permissions.skillEnabled(player, SkillType.EXCAVATION) && !mcMMO.placeStore.isTrue(blockState)) {
|
||||
else if (BlockUtils.affectedByGigaDrillBreaker(blockState) && ItemUtils.isShovel(heldItem) && Permissions.skillEnabled(player, SkillType.EXCAVATION) && !mcMMO.getPlaceStore().isTrue(blockState)) {
|
||||
ExcavationManager excavationManager = mcMMOPlayer.getExcavationManager();
|
||||
excavationManager.excavationBlockCheck(blockState);
|
||||
|
||||
@ -191,7 +191,7 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
|
||||
/* Remove metadata from placed watched blocks */
|
||||
mcMMO.placeStore.setFalse(blockState);
|
||||
mcMMO.getPlaceStore().setFalse(blockState);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -68,12 +68,12 @@ public class EntityListener implements Listener {
|
||||
Block block = event.getBlock();
|
||||
boolean isTracked = entity.hasMetadata(mcMMO.entityMetadataKey);
|
||||
|
||||
if (mcMMO.placeStore.isTrue(block) && !isTracked) {
|
||||
mcMMO.placeStore.setFalse(block);
|
||||
if (mcMMO.getPlaceStore().isTrue(block) && !isTracked) {
|
||||
mcMMO.getPlaceStore().setFalse(block);
|
||||
entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
|
||||
}
|
||||
else if (isTracked) {
|
||||
mcMMO.placeStore.setTrue(block);
|
||||
mcMMO.getPlaceStore().setTrue(block);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -193,7 +193,8 @@ public class PlayerListener implements Listener {
|
||||
|
||||
case CAUGHT_ENTITY:
|
||||
Entity entity = event.getCaught();
|
||||
|
||||
System.out.println(event.getState());
|
||||
System.out.println(entity);
|
||||
if (fishingManager.canShake(entity)) {
|
||||
fishingManager.shakeCheck((LivingEntity) entity);
|
||||
}
|
||||
@ -319,7 +320,7 @@ public class PlayerListener implements Listener {
|
||||
ItemStack heldItem = player.getItemInHand();
|
||||
|
||||
/* REPAIR CHECKS */
|
||||
if (blockID == Repair.repairAnvilId && Permissions.skillEnabled(player, SkillType.REPAIR) && mcMMO.repairableManager.isRepairable(heldItem)) {
|
||||
if (blockID == Repair.repairAnvilId && Permissions.skillEnabled(player, SkillType.REPAIR) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
|
||||
UserManager.getPlayer(player).getRepairManager().handleRepair(heldItem);
|
||||
event.setCancelled(true);
|
||||
player.updateInventory();
|
||||
|
@ -30,9 +30,9 @@ public class WorldListener implements Listener {
|
||||
public void onStructureGrow(StructureGrowEvent event) {
|
||||
Location location = event.getLocation();
|
||||
|
||||
if (mcMMO.placeStore.isTrue(location.getBlockX(), location.getBlockY(), location.getBlockZ(), location.getWorld())) {
|
||||
if (mcMMO.getPlaceStore().isTrue(location.getBlockX(), location.getBlockY(), location.getBlockZ(), location.getWorld())) {
|
||||
for (BlockState blockState : event.getBlocks()) {
|
||||
mcMMO.placeStore.setFalse(blockState);
|
||||
mcMMO.getPlaceStore().setFalse(blockState);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -65,7 +65,7 @@ public class WorldListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onWorldUnload(WorldUnloadEvent event) {
|
||||
mcMMO.placeStore.unloadWorld(event.getWorld());
|
||||
mcMMO.getPlaceStore().unloadWorld(event.getWorld());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -77,6 +77,6 @@ public class WorldListener implements Listener {
|
||||
public void onChunkUnload(ChunkUnloadEvent event) {
|
||||
Chunk chunk = event.getChunk();
|
||||
|
||||
mcMMO.placeStore.chunkUnloaded(chunk.getX(), chunk.getZ(), event.getWorld());
|
||||
mcMMO.getPlaceStore().chunkUnloaded(chunk.getX(), chunk.getZ(), event.getWorld());
|
||||
}
|
||||
}
|
||||
|
@ -64,9 +64,9 @@ public class mcMMO extends JavaPlugin {
|
||||
|
||||
public static mcMMO p;
|
||||
|
||||
public static ChunkManager placeStore;
|
||||
public static RepairableManager repairableManager;
|
||||
public static DatabaseManager databaseManager;
|
||||
private static ChunkManager placeStore;
|
||||
private static RepairableManager repairableManager;
|
||||
private static DatabaseManager databaseManager;
|
||||
|
||||
// Jar Stuff
|
||||
public static File mcmmo;
|
||||
@ -222,6 +222,18 @@ public class mcMMO extends JavaPlugin {
|
||||
getLogger().info("[Debug] " + message);
|
||||
}
|
||||
|
||||
public static ChunkManager getPlaceStore() {
|
||||
return placeStore;
|
||||
}
|
||||
|
||||
public static DatabaseManager getDatabaseManager() {
|
||||
return databaseManager;
|
||||
}
|
||||
|
||||
public static RepairableManager getRepairableManager() {
|
||||
return repairableManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the various storage file paths
|
||||
*/
|
||||
|
@ -21,11 +21,11 @@ public class StickyPistonTrackerTask extends BukkitRunnable {
|
||||
Block newBlock = block.getRelative(direction);
|
||||
Block originalBlock = newBlock.getRelative(direction);
|
||||
|
||||
if (originalBlock.getType() != Material.AIR || !mcMMO.placeStore.isTrue(originalBlock)) {
|
||||
if (originalBlock.getType() != Material.AIR || !mcMMO.getPlaceStore().isTrue(originalBlock)) {
|
||||
return;
|
||||
}
|
||||
|
||||
mcMMO.placeStore.setFalse(originalBlock);
|
||||
mcMMO.placeStore.setTrue(newBlock);
|
||||
mcMMO.getPlaceStore().setFalse(originalBlock);
|
||||
mcMMO.getPlaceStore().setTrue(newBlock);
|
||||
}
|
||||
}
|
||||
|
@ -8,10 +8,10 @@ import com.gmail.nossr50.config.Config;
|
||||
public class UserPurgeTask extends BukkitRunnable {
|
||||
@Override
|
||||
public void run() {
|
||||
mcMMO.databaseManager.purgePowerlessUsers();
|
||||
mcMMO.getDatabaseManager().purgePowerlessUsers();
|
||||
|
||||
if (Config.getInstance().getOldUsersCutoff() != -1) {
|
||||
mcMMO.databaseManager.purgeOldUsers();
|
||||
mcMMO.getDatabaseManager().purgeOldUsers();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ public class Herbalism {
|
||||
protected static int calculateCatciAndSugarDrops(BlockState blockState) {
|
||||
Block block = blockState.getBlock();
|
||||
Material blockType = blockState.getType();
|
||||
int dropAmount = mcMMO.placeStore.isTrue(block) ? 0 : 1;
|
||||
int dropAmount = mcMMO.getPlaceStore().isTrue(block) ? 0 : 1;
|
||||
|
||||
// Handle the two blocks above it - cacti & sugar cane can only grow 3 high naturally
|
||||
for (int y = 1; y < 3; y++) {
|
||||
@ -73,8 +73,8 @@ public class Herbalism {
|
||||
break;
|
||||
}
|
||||
|
||||
if (mcMMO.placeStore.isTrue(relativeBlock)) {
|
||||
mcMMO.placeStore.setFalse(relativeBlock);
|
||||
if (mcMMO.getPlaceStore().isTrue(relativeBlock)) {
|
||||
mcMMO.getPlaceStore().setFalse(relativeBlock);
|
||||
}
|
||||
else {
|
||||
dropAmount++;
|
||||
|
@ -118,7 +118,7 @@ public class HerbalismManager extends SkillManager {
|
||||
Material material = blockState.getType();
|
||||
boolean oneBlockPlant = !(material == Material.CACTUS || material == Material.SUGAR_CANE_BLOCK);
|
||||
|
||||
if (oneBlockPlant && mcMMO.placeStore.isTrue(blockState)) {
|
||||
if (oneBlockPlant && mcMMO.getPlaceStore().isTrue(blockState)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -206,8 +206,8 @@ public class HerbalismManager extends SkillManager {
|
||||
|
||||
case RED_ROSE:
|
||||
case YELLOW_FLOWER:
|
||||
if (mcMMO.placeStore.isTrue(blockState)) {
|
||||
mcMMO.placeStore.setFalse(blockState);
|
||||
if (mcMMO.getPlaceStore().isTrue(blockState)) {
|
||||
mcMMO.getPlaceStore().setFalse(blockState);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -139,13 +139,13 @@ public class MiningManager extends SkillManager{
|
||||
|
||||
for (BlockState blockState : ores) {
|
||||
if (Misc.getRandom().nextFloat() < (yield + oreBonus)) {
|
||||
if (!mcMMO.placeStore.isTrue(blockState)) {
|
||||
if (!mcMMO.getPlaceStore().isTrue(blockState)) {
|
||||
xp += Mining.getBlockXp(blockState);
|
||||
}
|
||||
|
||||
Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack(1)); // Initial block that would have been dropped
|
||||
|
||||
if (!mcMMO.placeStore.isTrue(blockState)) {
|
||||
if (!mcMMO.getPlaceStore().isTrue(blockState)) {
|
||||
for (int i = 1; i < dropMultiplier; i++) {
|
||||
Mining.handleSilkTouchDrops(blockState); // Bonus drops - should drop the block & not the items
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ public class RepairManager extends SkillManager {
|
||||
Player player = getPlayer();
|
||||
int itemId = item.getTypeId();
|
||||
|
||||
Repairable repairable = mcMMO.repairableManager.getRepairable(itemId);
|
||||
Repairable repairable = mcMMO.getRepairableManager().getRepairable(itemId);
|
||||
|
||||
// Permissions checks on material and item types
|
||||
if (!repairable.getRepairItemType().getPermissions(player)) {
|
||||
|
@ -25,7 +25,7 @@ public class SmeltingManager extends SkillManager {
|
||||
}
|
||||
|
||||
public boolean canUseFluxMining(BlockState blockState) {
|
||||
return getSkillLevel() >= Smelting.fluxMiningUnlockLevel && BlockUtils.affectedByFluxMining(blockState) && Permissions.fluxMining(getPlayer()) && !mcMMO.placeStore.isTrue(blockState);
|
||||
return getSkillLevel() >= Smelting.fluxMiningUnlockLevel && BlockUtils.affectedByFluxMining(blockState) && Permissions.fluxMining(getPlayer()) && !mcMMO.getPlaceStore().isTrue(blockState);
|
||||
}
|
||||
|
||||
public boolean canUseVanillaXpBoost() {
|
||||
|
@ -248,7 +248,7 @@ public final class Woodcutting {
|
||||
* @param treeFellerBlocks List of blocks to be removed
|
||||
*/
|
||||
private static void handleBlock(BlockState blockState, List<BlockState> futureCenterBlocks, List<BlockState> treeFellerBlocks) {
|
||||
if (!BlockUtils.affectedByTreeFeller(blockState) || mcMMO.placeStore.isTrue(blockState) || treeFellerBlocks.contains(blockState)) {
|
||||
if (!BlockUtils.affectedByTreeFeller(blockState) || mcMMO.getPlaceStore().isTrue(blockState) || treeFellerBlocks.contains(blockState)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ public class BlockStoreConversionZDirectory implements Runnable {
|
||||
this.world = world;
|
||||
this.scheduler = mcMMO.p.getServer().getScheduler();
|
||||
this.manager = new HashChunkletManager();
|
||||
this.newManager = (HashChunkManager) mcMMO.placeStore;
|
||||
this.newManager = (HashChunkManager) mcMMO.getPlaceStore();
|
||||
this.dataDir = dataDir;
|
||||
this.xDir = xDir;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user