mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-23 05:36:46 +01:00
Moved anvil placement handling into Repair.java
This commit is contained in:
parent
0ee05687d9
commit
77462888ff
@ -14,9 +14,11 @@ import com.gmail.nossr50.datatypes.SkillType;
|
|||||||
import com.gmail.nossr50.skills.Excavation;
|
import com.gmail.nossr50.skills.Excavation;
|
||||||
import com.gmail.nossr50.skills.Herbalism;
|
import com.gmail.nossr50.skills.Herbalism;
|
||||||
import com.gmail.nossr50.skills.Mining;
|
import com.gmail.nossr50.skills.Mining;
|
||||||
|
import com.gmail.nossr50.skills.Repair;
|
||||||
import com.gmail.nossr50.skills.Skills;
|
import com.gmail.nossr50.skills.Skills;
|
||||||
import com.gmail.nossr50.skills.WoodCutting;
|
import com.gmail.nossr50.skills.WoodCutting;
|
||||||
import com.gmail.nossr50.spout.SpoutSounds;
|
import com.gmail.nossr50.spout.SpoutSounds;
|
||||||
|
import com.gmail.nossr50.events.FakeBlockBreakEvent;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.CropState;
|
import org.bukkit.CropState;
|
||||||
@ -36,12 +38,9 @@ import org.bukkit.event.player.PlayerAnimationEvent;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.metadata.FixedMetadataValue;
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
|
|
||||||
import org.getspout.spoutapi.SpoutManager;
|
|
||||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
|
||||||
import org.getspout.spoutapi.sound.SoundEffect;
|
import org.getspout.spoutapi.sound.SoundEffect;
|
||||||
|
|
||||||
import com.gmail.nossr50.locale.mcLocale;
|
|
||||||
import com.gmail.nossr50.events.FakeBlockBreakEvent;
|
|
||||||
|
|
||||||
public class mcBlockListener implements Listener {
|
public class mcBlockListener implements Listener {
|
||||||
private final mcMMO plugin;
|
private final mcMMO plugin;
|
||||||
@ -109,7 +108,7 @@ public class mcBlockListener implements Listener {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Block newLocation = block.getRelative(0, y+1, 0);
|
Block newLocation = block.getRelative(0, y + 1, 0);
|
||||||
newLocation.setMetadata("mcmmoPlacedBlock", new FixedMetadataValue(plugin, true));
|
newLocation.setMetadata("mcmmoPlacedBlock", new FixedMetadataValue(plugin, true));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -122,22 +121,7 @@ public class mcBlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (id == LoadProperties.anvilID && LoadProperties.anvilmessages) {
|
if (id == LoadProperties.anvilID && LoadProperties.anvilmessages) {
|
||||||
PlayerProfile PP = Users.getProfile(player);
|
Repair.placedAnvilCheck(player, id);
|
||||||
|
|
||||||
if (!PP.getPlacedAnvil()) {
|
|
||||||
if (LoadProperties.spoutEnabled) {
|
|
||||||
SpoutPlayer sPlayer = SpoutManager.getPlayer(player);
|
|
||||||
|
|
||||||
if (sPlayer.isSpoutCraftEnabled()) {
|
|
||||||
sPlayer.sendNotification("[mcMMO] Anvil Placed", "Right click to repair!", Material.getMaterial(id));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
event.getPlayer().sendMessage(mcLocale.getString("mcBlockListener.PlacedAnvil"));
|
|
||||||
}
|
|
||||||
|
|
||||||
PP.togglePlacedAnvil();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,7 +138,7 @@ public class mcBlockListener implements Listener {
|
|||||||
Material mat = block.getType();
|
Material mat = block.getType();
|
||||||
ItemStack inhand = player.getItemInHand();
|
ItemStack inhand = player.getItemInHand();
|
||||||
|
|
||||||
if(event instanceof FakeBlockBreakEvent) {
|
if (event instanceof FakeBlockBreakEvent) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,8 @@ import org.bukkit.enchantments.Enchantment;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.PlayerInventory;
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
|
import org.getspout.spoutapi.SpoutManager;
|
||||||
|
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||||
|
|
||||||
import com.gmail.nossr50.ItemChecks;
|
import com.gmail.nossr50.ItemChecks;
|
||||||
import com.gmail.nossr50.Users;
|
import com.gmail.nossr50.Users;
|
||||||
@ -434,4 +436,29 @@ public class Repair {
|
|||||||
|
|
||||||
is.setDurability(getRepairAmount(is, player));
|
is.setDurability(getRepairAmount(is, player));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles notifications for placing an anvil.
|
||||||
|
*
|
||||||
|
* @param player The player placing the anvil
|
||||||
|
* @param anvilID The item ID of the anvil block
|
||||||
|
*/
|
||||||
|
public static void placedAnvilCheck(Player player, int anvilID) {
|
||||||
|
PlayerProfile PP = Users.getProfile(player);
|
||||||
|
|
||||||
|
if (!PP.getPlacedAnvil()) {
|
||||||
|
if (LoadProperties.spoutEnabled) {
|
||||||
|
SpoutPlayer sPlayer = SpoutManager.getPlayer(player);
|
||||||
|
|
||||||
|
if (sPlayer.isSpoutCraftEnabled()) {
|
||||||
|
sPlayer.sendNotification("[mcMMO] Anvil Placed", "Right click to repair!", Material.getMaterial(anvilID)); //TODO: Use Locale
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
player.sendMessage(mcLocale.getString("mcBlockListener.PlacedAnvil"));
|
||||||
|
}
|
||||||
|
|
||||||
|
PP.togglePlacedAnvil();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user