mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-02 08:39:49 +01:00
PlayerListener cleanup
This commit is contained in:
parent
9dac898c1c
commit
76a987e1e0
@ -14,10 +14,11 @@ import com.gmail.nossr50.util.Misc;
|
|||||||
public class XprateCommand implements CommandExecutor {
|
public class XprateCommand implements CommandExecutor {
|
||||||
private final mcMMO plugin;
|
private final mcMMO plugin;
|
||||||
private static double oldRate = Config.getInstance().xpGainMultiplier;
|
private static double oldRate = Config.getInstance().xpGainMultiplier;
|
||||||
private static boolean xpEvent = false;
|
private boolean xpEvent;
|
||||||
|
|
||||||
public XprateCommand (mcMMO plugin) {
|
public XprateCommand (mcMMO plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
this.xpEvent = plugin.isXPEventEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -39,6 +40,7 @@ public class XprateCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
xpEvent = !xpEvent;
|
xpEvent = !xpEvent;
|
||||||
|
plugin.setXPEventEnabled(xpEvent);
|
||||||
Config.getInstance().xpGainMultiplier = oldRate;
|
Config.getInstance().xpGainMultiplier = oldRate;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -60,6 +62,7 @@ public class XprateCommand implements CommandExecutor {
|
|||||||
|
|
||||||
if (args[1].equalsIgnoreCase("true") || args[1].equalsIgnoreCase("false")) {
|
if (args[1].equalsIgnoreCase("true") || args[1].equalsIgnoreCase("false")) {
|
||||||
xpEvent = Boolean.valueOf(args[1]);
|
xpEvent = Boolean.valueOf(args[1]);
|
||||||
|
plugin.setXPEventEnabled(xpEvent);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sender.sendMessage(usage3);
|
sender.sendMessage(usage3);
|
||||||
@ -90,8 +93,4 @@ public class XprateCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isXpEventRunning() {
|
|
||||||
return xpEvent;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -280,8 +280,8 @@ public class BlockListener implements Listener {
|
|||||||
/*
|
/*
|
||||||
* ABILITY PREPARATION CHECKS
|
* ABILITY PREPARATION CHECKS
|
||||||
*/
|
*/
|
||||||
if (BlockChecks.abilityBlockCheck(block)) {
|
if (BlockChecks.canActivateAbilities(block)) {
|
||||||
if (profile.getToolPreparationMode(ToolType.HOE) && (BlockChecks.canBeGreenTerra(block) || BlockChecks.makeMossy(block))) {
|
if (profile.getToolPreparationMode(ToolType.HOE) && (BlockChecks.canBeGreenTerra(block) || BlockChecks.canMakeMossy(block))) {
|
||||||
Skills.abilityCheck(player, SkillType.HERBALISM);
|
Skills.abilityCheck(player, SkillType.HERBALISM);
|
||||||
}
|
}
|
||||||
else if (profile.getToolPreparationMode(ToolType.AXE) && BlockChecks.isLog(block) && Permissions.treeFeller(player)) { //TODO: Why are we checking the permissions here?
|
else if (profile.getToolPreparationMode(ToolType.AXE) && BlockChecks.isLog(block) && Permissions.treeFeller(player)) { //TODO: Why are we checking the permissions here?
|
||||||
@ -306,7 +306,7 @@ public class BlockListener implements Listener {
|
|||||||
/*
|
/*
|
||||||
* ABILITY TRIGGER CHECKS
|
* ABILITY TRIGGER CHECKS
|
||||||
*/
|
*/
|
||||||
if (profile.getAbilityMode(AbilityType.GREEN_TERRA) && Permissions.greenTerra(player) && BlockChecks.makeMossy(block)) {
|
if (profile.getAbilityMode(AbilityType.GREEN_TERRA) && Permissions.greenTerra(player) && BlockChecks.canMakeMossy(block)) {
|
||||||
Herbalism.greenTerra(player, block);
|
Herbalism.greenTerra(player, block);
|
||||||
}
|
}
|
||||||
else if (profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) && Skills.triggerCheck(player, block, AbilityType.GIGA_DRILL_BREAKER)) {
|
else if (profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) && Skills.triggerCheck(player, block, AbilityType.GIGA_DRILL_BREAKER)) {
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
package com.gmail.nossr50.listeners;
|
package com.gmail.nossr50.listeners;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.Action;
|
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
@ -22,22 +20,21 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.bukkit.plugin.PluginDescriptionFile;
|
import org.bukkit.plugin.PluginDescriptionFile;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.commands.general.XprateCommand;
|
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||||
import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
|
|
||||||
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.party.Party;
|
|
||||||
import com.gmail.nossr50.runnables.BleedTimer;
|
import com.gmail.nossr50.runnables.BleedTimer;
|
||||||
import com.gmail.nossr50.skills.SkillType;
|
import com.gmail.nossr50.skills.SkillType;
|
||||||
import com.gmail.nossr50.skills.Skills;
|
import com.gmail.nossr50.skills.Skills;
|
||||||
import com.gmail.nossr50.skills.fishing.Fishing;
|
import com.gmail.nossr50.skills.fishing.Fishing;
|
||||||
import com.gmail.nossr50.skills.herbalism.Herbalism;
|
import com.gmail.nossr50.skills.herbalism.Herbalism;
|
||||||
|
import com.gmail.nossr50.skills.mining.BlastMining;
|
||||||
import com.gmail.nossr50.skills.mining.MiningManager;
|
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||||
|
import com.gmail.nossr50.skills.repair.Repair;
|
||||||
import com.gmail.nossr50.skills.repair.Salvage;
|
import com.gmail.nossr50.skills.repair.Salvage;
|
||||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||||
import com.gmail.nossr50.util.BlockChecks;
|
import com.gmail.nossr50.util.BlockChecks;
|
||||||
|
import com.gmail.nossr50.util.ChatManager;
|
||||||
import com.gmail.nossr50.util.Item;
|
import com.gmail.nossr50.util.Item;
|
||||||
import com.gmail.nossr50.util.MOTD;
|
import com.gmail.nossr50.util.MOTD;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
@ -168,8 +165,7 @@ public class PlayerListener implements Listener {
|
|||||||
motd.displayWebsite(pluginDescription.getWebsite());
|
motd.displayWebsite(pluginDescription.getWebsite());
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: MAKE THIS SUCK LESS. THIS IS VERY BAD WAY TO DO THINGS, NEED BETTER WAY
|
if (plugin.isXPEventEnabled()) {
|
||||||
if (XprateCommand.isXpEventRunning()) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("XPRate.Event", new Object[] {Config.getInstance().xpGainMultiplier}));
|
player.sendMessage(LocaleLoader.getString("XPRate.Event", new Object[] {Config.getInstance().xpGainMultiplier}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -191,84 +187,110 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Monitor PlayerInteract events.
|
* Handle PlayerInteract events that involve modifying the event.
|
||||||
*
|
*
|
||||||
* @param event The event to watch
|
* @param event The event to watch
|
||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
public void onPlayerInteractLowest(PlayerInteractEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
|
||||||
Action action = event.getAction();
|
if (Misc.isNPC(player)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Block block = event.getClickedBlock();
|
Block block = event.getClickedBlock();
|
||||||
ItemStack inHand = player.getItemInHand();
|
ItemStack heldItem = event.getItem();
|
||||||
Material material;
|
|
||||||
|
|
||||||
/* Fix for NPE on interacting with air */
|
switch (event.getAction()) {
|
||||||
if (block == null) {
|
|
||||||
material = Material.AIR;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
material = block.getType();
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (action) {
|
|
||||||
case RIGHT_CLICK_BLOCK:
|
case RIGHT_CLICK_BLOCK:
|
||||||
|
int blockID = block.getTypeId();
|
||||||
|
|
||||||
/* REPAIR CHECKS */
|
/* REPAIR CHECKS */
|
||||||
if (Permissions.repair(player) && block.getTypeId() == Config.getInstance().getRepairAnvilId()) {
|
if (blockID == Repair.anvilID && Permissions.repair(player) && mcMMO.repairManager.isRepairable(heldItem)) {
|
||||||
if (mcMMO.repairManager.isRepairable(inHand)) {
|
mcMMO.repairManager.handleRepair(player, heldItem);
|
||||||
mcMMO.repairManager.handleRepair(player, inHand);
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
/* SALVAGE CHECKS */
|
/* SALVAGE CHECKS */
|
||||||
if (Permissions.salvage(player) && block.getTypeId() == Config.getInstance().getSalvageAnvilId()) {
|
else if (blockID == Salvage.anvilID && Permissions.salvage(player) && Salvage.isSalvageable(heldItem)) {
|
||||||
if (Salvage.isSalvageable(inHand)) {
|
Salvage.handleSalvage(player, block.getLocation(), heldItem);
|
||||||
final Location location = block.getLocation();
|
|
||||||
Salvage.handleSalvage(player, location, inHand);
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* ACTIVATION CHECKS */
|
|
||||||
if (Config.getInstance().getAbilitiesEnabled() && BlockChecks.abilityBlockCheck(block)) {
|
|
||||||
if (!material.equals(Material.DIRT) && !material.equals(Material.GRASS) && !material.equals(Material.SOIL)) {
|
|
||||||
Skills.activationCheck(player, SkillType.HERBALISM);
|
|
||||||
}
|
|
||||||
|
|
||||||
Skills.activationCheck(player, SkillType.AXES);
|
|
||||||
Skills.activationCheck(player, SkillType.EXCAVATION);
|
|
||||||
Skills.activationCheck(player, SkillType.MINING);
|
|
||||||
Skills.activationCheck(player, SkillType.SWORDS);
|
|
||||||
Skills.activationCheck(player, SkillType.UNARMED);
|
|
||||||
Skills.activationCheck(player, SkillType.WOODCUTTING);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* GREEN THUMB CHECK */
|
|
||||||
if (inHand.getType().equals(Material.SEEDS) && BlockChecks.makeMossy(block) && Permissions.greenThumbBlocks(player)) {
|
|
||||||
Herbalism.greenThumbBlocks(inHand, player, block);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ITEM CHECKS */
|
|
||||||
if (BlockChecks.abilityBlockCheck(block)) {
|
|
||||||
Item.itemChecks(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* BLAST MINING CHECK */
|
/* BLAST MINING CHECK */
|
||||||
if (player.isSneaking() && inHand.getTypeId() == Config.getInstance().getDetonatorItemID() && Permissions.blastMining(player)) {
|
else if (player.isSneaking() && Permissions.blastMining(player) && heldItem.getTypeId() == BlastMining.detonatorID) {
|
||||||
MiningManager miningManager = new MiningManager(player);
|
MiningManager miningManager = new MiningManager(player);
|
||||||
miningManager.detonate(event);
|
miningManager.detonate(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case RIGHT_CLICK_AIR:
|
||||||
|
|
||||||
|
/* BLAST MINING CHECK */
|
||||||
|
if (player.isSneaking() && Permissions.blastMining(player) && heldItem.getTypeId() == BlastMining.detonatorID) {
|
||||||
|
MiningManager miningManager = new MiningManager(player);
|
||||||
|
miningManager.detonate(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Monitor PlayerInteract events.
|
||||||
|
*
|
||||||
|
* @param event The event to watch
|
||||||
|
*/
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
|
if (Misc.isNPC(player)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Block block = event.getClickedBlock();
|
||||||
|
ItemStack heldItem = event.getItem();
|
||||||
|
|
||||||
|
switch (event.getAction()) {
|
||||||
|
case RIGHT_CLICK_BLOCK:
|
||||||
|
|
||||||
|
/* ACTIVATION & ITEM CHECKS */
|
||||||
|
if (BlockChecks.canActivateAbilities(block)) {
|
||||||
|
if (Skills.abilitiesEnabled) {
|
||||||
|
if (BlockChecks.canActivateHerbalism(block)) {
|
||||||
|
Skills.activationCheck(player, SkillType.HERBALISM);
|
||||||
|
}
|
||||||
|
|
||||||
|
Skills.activationCheck(player, SkillType.AXES);
|
||||||
|
Skills.activationCheck(player, SkillType.EXCAVATION);
|
||||||
|
Skills.activationCheck(player, SkillType.MINING);
|
||||||
|
Skills.activationCheck(player, SkillType.SWORDS);
|
||||||
|
Skills.activationCheck(player, SkillType.UNARMED);
|
||||||
|
Skills.activationCheck(player, SkillType.WOODCUTTING);
|
||||||
|
}
|
||||||
|
|
||||||
|
Item.itemChecks(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* GREEN THUMB CHECK */
|
||||||
|
if (heldItem.getType() == Material.SEEDS && BlockChecks.canMakeMossy(block) && Permissions.greenThumbBlocks(player)) {
|
||||||
|
Herbalism.greenThumbBlocks(heldItem, player, block);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
case RIGHT_CLICK_AIR:
|
case RIGHT_CLICK_AIR:
|
||||||
|
|
||||||
/* ACTIVATION CHECKS */
|
/* ACTIVATION CHECKS */
|
||||||
if (Config.getInstance().getAbilitiesEnabled()) {
|
if (Skills.abilitiesEnabled) {
|
||||||
Skills.activationCheck(player, SkillType.AXES);
|
Skills.activationCheck(player, SkillType.AXES);
|
||||||
Skills.activationCheck(player, SkillType.EXCAVATION);
|
Skills.activationCheck(player, SkillType.EXCAVATION);
|
||||||
Skills.activationCheck(player, SkillType.HERBALISM);
|
Skills.activationCheck(player, SkillType.HERBALISM);
|
||||||
@ -281,12 +303,6 @@ public class PlayerListener implements Listener {
|
|||||||
/* ITEM CHECKS */
|
/* ITEM CHECKS */
|
||||||
Item.itemChecks(player);
|
Item.itemChecks(player);
|
||||||
|
|
||||||
/* BLAST MINING CHECK */
|
|
||||||
if (player.isSneaking() && inHand.getTypeId() == Config.getInstance().getDetonatorItemID() && Permissions.blastMining(player)) {
|
|
||||||
MiningManager miningManager = new MiningManager(player);
|
|
||||||
miningManager.detonate(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LEFT_CLICK_AIR:
|
case LEFT_CLICK_AIR:
|
||||||
@ -294,7 +310,7 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
/* CALL OF THE WILD CHECKS */
|
/* CALL OF THE WILD CHECKS */
|
||||||
if (player.isSneaking()) {
|
if (player.isSneaking()) {
|
||||||
Material type = inHand.getType();
|
Material type = heldItem.getType();
|
||||||
|
|
||||||
if (type == Material.RAW_FISH) {
|
if (type == Material.RAW_FISH) {
|
||||||
TamingManager tamingManager = new TamingManager(player);
|
TamingManager tamingManager = new TamingManager(player);
|
||||||
@ -328,48 +344,12 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (profile.getPartyChatMode()) {
|
if (profile.getPartyChatMode()) {
|
||||||
Party party = profile.getParty();
|
ChatManager chatManager = new ChatManager(plugin, player, event);
|
||||||
|
chatManager.handlePartyChat();
|
||||||
if (party == null) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.Party.None"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String partyName = party.getName();
|
|
||||||
String playerName = player.getName();
|
|
||||||
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(playerName, partyName, event.getMessage());
|
|
||||||
plugin.getServer().getPluginManager().callEvent(chatEvent);
|
|
||||||
|
|
||||||
if (chatEvent.isCancelled()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
plugin.getLogger().info("[P](" + partyName + ")" + "<" + playerName + "> " + chatEvent.getMessage());
|
|
||||||
|
|
||||||
for (Player member : party.getOnlineMembers()) {
|
|
||||||
member.sendMessage(LocaleLoader.getString("Commands.Party.Chat.Prefix", new Object[] {playerName}) + chatEvent.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
}
|
||||||
else if (profile.getAdminChatMode()) {
|
else if (profile.getAdminChatMode()) {
|
||||||
String playerName = player.getName();
|
ChatManager chatManager = new ChatManager(plugin, player, event);
|
||||||
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(playerName, event.getMessage());
|
chatManager.handleAdminChat();
|
||||||
plugin.getServer().getPluginManager().callEvent(chatEvent);
|
|
||||||
|
|
||||||
if (chatEvent.isCancelled()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
plugin.getLogger().info("[A]<" + playerName + "> " + chatEvent.getMessage());
|
|
||||||
|
|
||||||
for (Player otherPlayer : plugin.getServer().getOnlinePlayers()) {
|
|
||||||
if (Permissions.adminChat(otherPlayer) || otherPlayer.isOp()) {
|
|
||||||
otherPlayer.sendMessage(LocaleLoader.getString("Commands.AdminChat.Prefix", new Object[] {playerName}) + chatEvent.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -385,8 +365,10 @@ public class PlayerListener implements Listener {
|
|||||||
String lowerCaseCommand = command.toLowerCase();
|
String lowerCaseCommand = command.toLowerCase();
|
||||||
|
|
||||||
if (plugin.commandIsAliased(lowerCaseCommand)) {
|
if (plugin.commandIsAliased(lowerCaseCommand)) {
|
||||||
//We should find a better way to avoid string replacement where the alias is equals to the command
|
String commandAlias = plugin.getCommandAlias(lowerCaseCommand);
|
||||||
if (command.equals(plugin.getCommandAlias(lowerCaseCommand))) {
|
|
||||||
|
//TODO: We should find a better way to avoid string replacement where the alias is equals to the command
|
||||||
|
if (command.equals(commandAlias)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,6 +119,9 @@ public class mcMMO extends JavaPlugin {
|
|||||||
//Spout Check
|
//Spout Check
|
||||||
public static boolean spoutEnabled;
|
public static boolean spoutEnabled;
|
||||||
|
|
||||||
|
//XP Event Check
|
||||||
|
private boolean xpEventEnabled = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Things to be run when the plugin is enabled.
|
* Things to be run when the plugin is enabled.
|
||||||
*/
|
*/
|
||||||
@ -560,5 +563,13 @@ public class mcMMO extends JavaPlugin {
|
|||||||
public static Database getPlayerDatabase() {
|
public static Database getPlayerDatabase() {
|
||||||
return database;
|
return database;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isXPEventEnabled() {
|
||||||
|
return xpEventEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setXPEventEnabled(boolean enabled) {
|
||||||
|
this.xpEventEnabled = enabled;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ public enum AbilityType {
|
|||||||
return BlockChecks.canBeGigaDrillBroken(block);
|
return BlockChecks.canBeGigaDrillBroken(block);
|
||||||
|
|
||||||
case GREEN_TERRA:
|
case GREEN_TERRA:
|
||||||
return BlockChecks.makeMossy(block);
|
return BlockChecks.canMakeMossy(block);
|
||||||
|
|
||||||
case LEAF_BLOWER:
|
case LEAF_BLOWER:
|
||||||
return block.getType() == Material.LEAVES;
|
return block.getType() == Material.LEAVES;
|
||||||
|
@ -23,6 +23,7 @@ import com.gmail.nossr50.util.Users;
|
|||||||
public class Skills {
|
public class Skills {
|
||||||
static AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
static AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
||||||
public static int abilityLengthIncreaseLevel = advancedConfig.getAbilityLength();
|
public static int abilityLengthIncreaseLevel = advancedConfig.getAbilityLength();
|
||||||
|
public static boolean abilitiesEnabled = Config.getInstance().getAbilitiesEnabled();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks to see if the cooldown for an item or ability is expired.
|
* Checks to see if the cooldown for an item or ability is expired.
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.gmail.nossr50.skills.mining;
|
package com.gmail.nossr50.skills.mining;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
|
import com.gmail.nossr50.config.Config;
|
||||||
|
|
||||||
public class BlastMining {
|
public class BlastMining {
|
||||||
public static int rank1 = AdvancedConfig.getInstance().getBlastMiningRank1();
|
public static int rank1 = AdvancedConfig.getInstance().getBlastMiningRank1();
|
||||||
@ -12,5 +13,7 @@ public class BlastMining {
|
|||||||
public static int rank7 = AdvancedConfig.getInstance().getBlastMiningRank7();
|
public static int rank7 = AdvancedConfig.getInstance().getBlastMiningRank7();
|
||||||
public static int rank8 = AdvancedConfig.getInstance().getBlastMiningRank8();
|
public static int rank8 = AdvancedConfig.getInstance().getBlastMiningRank8();
|
||||||
|
|
||||||
|
public static int detonatorID = Config.getInstance().getDetonatorItemID();
|
||||||
|
|
||||||
public final static int MAXIMUM_REMOTE_DETONATION_DISTANCE = 100;
|
public final static int MAXIMUM_REMOTE_DETONATION_DISTANCE = 100;
|
||||||
}
|
}
|
||||||
|
@ -27,10 +27,6 @@ public class MiningManager extends SkillManager{
|
|||||||
* @param plugin mcMMO plugin instance
|
* @param plugin mcMMO plugin instance
|
||||||
*/
|
*/
|
||||||
public void detonate(PlayerInteractEvent event) {
|
public void detonate(PlayerInteractEvent event) {
|
||||||
if (Misc.isNPC(player)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (skillLevel < BlastMining.rank1) {
|
if (skillLevel < BlastMining.rank1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import org.getspout.spoutapi.player.SpoutPlayer;
|
|||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.SkillType;
|
import com.gmail.nossr50.skills.SkillType;
|
||||||
@ -33,6 +34,8 @@ public class Repair {
|
|||||||
public static boolean arcaneForgingDowngrades = advancedConfig.getArcaneForgingDowngradeEnabled();
|
public static boolean arcaneForgingDowngrades = advancedConfig.getArcaneForgingDowngradeEnabled();
|
||||||
public static boolean arcaneForgingEnchantLoss = advancedConfig.getArcaneForgingEnchantLossEnabled();
|
public static boolean arcaneForgingEnchantLoss = advancedConfig.getArcaneForgingEnchantLossEnabled();
|
||||||
|
|
||||||
|
public static int anvilID = Config.getInstance().getRepairAnvilId();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle the XP gain for repair events.
|
* Handle the XP gain for repair events.
|
||||||
*
|
*
|
||||||
|
@ -15,15 +15,15 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
|||||||
import com.gmail.nossr50.skills.SkillType;
|
import com.gmail.nossr50.skills.SkillType;
|
||||||
import com.gmail.nossr50.util.ItemChecks;
|
import com.gmail.nossr50.util.ItemChecks;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public class Salvage {
|
public class Salvage {
|
||||||
private static Config configInstance = Config.getInstance();
|
private static Config configInstance = Config.getInstance();
|
||||||
public static int salvageUnlockLevel = Config.getInstance().getSalvageUnlockLevel();
|
public static int salvageUnlockLevel = Config.getInstance().getSalvageUnlockLevel();
|
||||||
|
public static int anvilID = Config.getInstance().getSalvageAnvilId();
|
||||||
|
|
||||||
public static void handleSalvage(final Player player, final Location location, final ItemStack inHand) {
|
public static void handleSalvage(final Player player, final Location location, final ItemStack inHand) {
|
||||||
if (!Permissions.salvage(player) || !configInstance.getSalvageEnabled()) {
|
if (!configInstance.getSalvageEnabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,9 +162,6 @@ public class TamingManager extends SkillManager {
|
|||||||
* @param summonAmount The amount of material needed to summon the entity
|
* @param summonAmount The amount of material needed to summon the entity
|
||||||
*/
|
*/
|
||||||
private void callOfTheWild(EntityType type, int summonAmount) {
|
private void callOfTheWild(EntityType type, int summonAmount) {
|
||||||
if (player == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!Permissions.callOfTheWild(player)) {
|
if (!Permissions.callOfTheWild(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ public class BlockChecks {
|
|||||||
* @param block Block to check
|
* @param block Block to check
|
||||||
* @return true if the block should allow ability activation, false otherwise
|
* @return true if the block should allow ability activation, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean abilityBlockCheck(Block block) {
|
public static boolean canActivateAbilities(Block block) {
|
||||||
ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1);
|
ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1);
|
||||||
|
|
||||||
if (customBlocksEnabled && CustomBlocksConfig.getInstance().customAbilityBlocks.contains(item)) {
|
if (customBlocksEnabled && CustomBlocksConfig.getInstance().customAbilityBlocks.contains(item)) {
|
||||||
@ -151,7 +151,7 @@ public class BlockChecks {
|
|||||||
* @param block The block to check
|
* @param block The block to check
|
||||||
* @return true if the block can be made mossy, false otherwise
|
* @return true if the block can be made mossy, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean makeMossy(Block block) {
|
public static boolean canMakeMossy(Block block) {
|
||||||
switch (block.getType()) {
|
switch (block.getType()) {
|
||||||
case COBBLESTONE:
|
case COBBLESTONE:
|
||||||
case DIRT:
|
case DIRT:
|
||||||
@ -314,4 +314,16 @@ public class BlockChecks {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean canActivateHerbalism(Block block) {
|
||||||
|
switch (block.getType()) {
|
||||||
|
case DIRT:
|
||||||
|
case GRASS:
|
||||||
|
case SOIL:
|
||||||
|
return false;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
73
src/main/java/com/gmail/nossr50/util/ChatManager.java
Normal file
73
src/main/java/com/gmail/nossr50/util/ChatManager.java
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
package com.gmail.nossr50.util;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
|
||||||
|
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.party.Party;
|
||||||
|
|
||||||
|
public class ChatManager {
|
||||||
|
private mcMMO plugin;
|
||||||
|
private Player player;
|
||||||
|
private String playerName;
|
||||||
|
private AsyncPlayerChatEvent event;
|
||||||
|
|
||||||
|
public ChatManager (mcMMO plugin, Player player, AsyncPlayerChatEvent event) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.player = player;
|
||||||
|
this.playerName = player.getName();
|
||||||
|
this.event = event;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void handleAdminChat() {
|
||||||
|
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(playerName, event.getMessage());
|
||||||
|
plugin.getServer().getPluginManager().callEvent(chatEvent);
|
||||||
|
|
||||||
|
if (chatEvent.isCancelled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String adminMessage = chatEvent.getMessage();
|
||||||
|
|
||||||
|
plugin.getLogger().info("[A]<" + playerName + "> " + adminMessage);
|
||||||
|
|
||||||
|
for (Player otherPlayer : plugin.getServer().getOnlinePlayers()) {
|
||||||
|
if (Permissions.adminChat(otherPlayer) || otherPlayer.isOp()) {
|
||||||
|
otherPlayer.sendMessage(LocaleLoader.getString("Commands.AdminChat.Prefix", new Object[] {playerName}) + adminMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void handlePartyChat() {
|
||||||
|
Party party = Users.getProfile(player).getParty();
|
||||||
|
|
||||||
|
if (party == null) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Commands.Party.None"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String partyName = party.getName();
|
||||||
|
|
||||||
|
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(playerName, partyName, event.getMessage());
|
||||||
|
plugin.getServer().getPluginManager().callEvent(chatEvent);
|
||||||
|
|
||||||
|
if (chatEvent.isCancelled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String partyMessage = chatEvent.getMessage();
|
||||||
|
|
||||||
|
plugin.getLogger().info("[P](" + partyName + ")" + "<" + playerName + "> " + partyMessage);
|
||||||
|
|
||||||
|
for (Player member : party.getOnlineMembers()) {
|
||||||
|
member.sendMessage(LocaleLoader.getString("Commands.Party.Chat.Prefix", new Object[] {playerName}) + partyMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user