mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-29 16:46:46 +01:00
I should be more descriptive with my commits. So here goes.
Made mcMMO play nice with servers not running Spout. Moved onCommand stuff into its own Object. Changed a few things around involving passing plugin.
This commit is contained in:
parent
263dc26380
commit
64e7bb4213
1521
mcMMO/com/gmail/nossr50/command/Commands.java
Normal file
1521
mcMMO/com/gmail/nossr50/command/Commands.java
Normal file
File diff suppressed because it is too large
Load Diff
@ -7,6 +7,8 @@ import org.bukkit.ChatColor;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.Event.Priority;
|
||||||
import org.getspout.spoutapi.SpoutManager;
|
import org.getspout.spoutapi.SpoutManager;
|
||||||
import org.getspout.spoutapi.gui.GenericTexture;
|
import org.getspout.spoutapi.gui.GenericTexture;
|
||||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||||
@ -17,12 +19,18 @@ import com.gmail.nossr50.Users;
|
|||||||
import com.gmail.nossr50.m;
|
import com.gmail.nossr50.m;
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.SkillType;
|
import com.gmail.nossr50.datatypes.SkillType;
|
||||||
|
import com.gmail.nossr50.listeners.mcSpoutListener;
|
||||||
|
|
||||||
public class SpoutStuff
|
public class SpoutStuff
|
||||||
{
|
{
|
||||||
|
private final static mcSpoutListener spoutListener = new mcSpoutListener();
|
||||||
public static HashMap<Player, GenericTexture> xpbars = new HashMap<Player, GenericTexture>();
|
public static HashMap<Player, GenericTexture> xpbars = new HashMap<Player, GenericTexture>();
|
||||||
public static HashMap<Player, GenericTexture> xpicons = new HashMap<Player, GenericTexture>();
|
public static HashMap<Player, GenericTexture> xpicons = new HashMap<Player, GenericTexture>();
|
||||||
|
|
||||||
|
public static void registerCustomEvent()
|
||||||
|
{
|
||||||
|
Bukkit.getServer().getPluginManager().registerEvent(Event.Type.CUSTOM_EVENT, spoutListener, Priority.Normal, Bukkit.getServer().getPluginManager().getPlugin("mcMMO"));
|
||||||
|
}
|
||||||
public static void playSoundForPlayer(SoundEffect effect, Player player, Location location)
|
public static void playSoundForPlayer(SoundEffect effect, Player player, Location location)
|
||||||
{
|
{
|
||||||
//Contrib stuff
|
//Contrib stuff
|
||||||
|
@ -856,6 +856,8 @@ public class PlayerProfile
|
|||||||
} else {
|
} else {
|
||||||
skillsXp.put(skillType, skillsXp.get(skillType)+newvalue);
|
skillsXp.put(skillType, skillsXp.get(skillType)+newvalue);
|
||||||
|
|
||||||
|
if(LoadProperties.spoutEnabled)
|
||||||
|
{
|
||||||
SkillType prevLastGained = lastgained;
|
SkillType prevLastGained = lastgained;
|
||||||
|
|
||||||
lastgained = skillType;
|
lastgained = skillType;
|
||||||
@ -864,6 +866,7 @@ public class PlayerProfile
|
|||||||
if(prevLastGained != skillType || prevLastGained == null)
|
if(prevLastGained != skillType || prevLastGained == null)
|
||||||
xpbarinc = SpoutStuff.getXpInc(this.getSkillXpLevel(lastgained), this.getXpToLevel(lastgained));
|
xpbarinc = SpoutStuff.getXpInc(this.getSkillXpLevel(lastgained), this.getXpToLevel(lastgained));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
//save();
|
//save();
|
||||||
}
|
}
|
||||||
public void removeXP(SkillType skillType, int newvalue)
|
public void removeXP(SkillType skillType, int newvalue)
|
||||||
|
@ -190,7 +190,7 @@ public class mcBlockListener extends BlockListener
|
|||||||
if(mcPermissions.getInstance().woodCuttingAbility(player)
|
if(mcPermissions.getInstance().woodCuttingAbility(player)
|
||||||
&& PP.getTreeFellerMode()
|
&& PP.getTreeFellerMode()
|
||||||
&& block.getTypeId() == 17
|
&& block.getTypeId() == 17
|
||||||
&& m.blockBreakSimulate(block, player, plugin))
|
&& m.blockBreakSimulate(block, player))
|
||||||
{
|
{
|
||||||
if(LoadProperties.spoutEnabled)
|
if(LoadProperties.spoutEnabled)
|
||||||
SpoutStuff.playSoundForPlayer(SoundEffect.EXPLODE, player, block.getLocation());
|
SpoutStuff.playSoundForPlayer(SoundEffect.EXPLODE, player, block.getLocation());
|
||||||
@ -302,7 +302,7 @@ public class mcBlockListener extends BlockListener
|
|||||||
/*
|
/*
|
||||||
* GIGA DRILL BREAKER CHECKS
|
* GIGA DRILL BREAKER CHECKS
|
||||||
*/
|
*/
|
||||||
if(PP.getGigaDrillBreakerMode() && m.blockBreakSimulate(block, player, plugin)
|
if(PP.getGigaDrillBreakerMode() && m.blockBreakSimulate(block, player)
|
||||||
&& Excavation.canBeGigaDrillBroken(block) && m.isShovel(inhand))
|
&& Excavation.canBeGigaDrillBroken(block) && m.isShovel(inhand))
|
||||||
{
|
{
|
||||||
int x = 0;
|
int x = 0;
|
||||||
@ -339,7 +339,7 @@ public class mcBlockListener extends BlockListener
|
|||||||
* BERSERK MODE CHECKS
|
* BERSERK MODE CHECKS
|
||||||
*/
|
*/
|
||||||
if(PP.getBerserkMode()
|
if(PP.getBerserkMode()
|
||||||
&& m.blockBreakSimulate(block, player, plugin)
|
&& m.blockBreakSimulate(block, player)
|
||||||
&& player.getItemInHand().getTypeId() == 0
|
&& player.getItemInHand().getTypeId() == 0
|
||||||
&& (Excavation.canBeGigaDrillBroken(block) || block.getTypeId() == 78))
|
&& (Excavation.canBeGigaDrillBroken(block) || block.getTypeId() == 78))
|
||||||
{
|
{
|
||||||
@ -363,7 +363,7 @@ public class mcBlockListener extends BlockListener
|
|||||||
*/
|
*/
|
||||||
if(PP.getSuperBreakerMode()
|
if(PP.getSuperBreakerMode()
|
||||||
&& Mining.canBeSuperBroken(block)
|
&& Mining.canBeSuperBroken(block)
|
||||||
&& m.blockBreakSimulate(block, player, plugin))
|
&& m.blockBreakSimulate(block, player))
|
||||||
{
|
{
|
||||||
|
|
||||||
if(LoadProperties.miningrequirespickaxe)
|
if(LoadProperties.miningrequirespickaxe)
|
||||||
@ -378,7 +378,7 @@ public class mcBlockListener extends BlockListener
|
|||||||
/*
|
/*
|
||||||
* LEAF BLOWER
|
* LEAF BLOWER
|
||||||
*/
|
*/
|
||||||
if(block.getTypeId() == 18 && mcPermissions.getInstance().woodcutting(player) && PP.getSkillLevel(SkillType.WOODCUTTING) >= 100 && m.isAxes(player.getItemInHand()) && m.blockBreakSimulate(block, player, plugin))
|
if(block.getTypeId() == 18 && mcPermissions.getInstance().woodcutting(player) && PP.getSkillLevel(SkillType.WOODCUTTING) >= 100 && m.isAxes(player.getItemInHand()) && m.blockBreakSimulate(block, player))
|
||||||
{
|
{
|
||||||
m.damageTool(player, (short)1);
|
m.damageTool(player, (short)1);
|
||||||
if(Math.random() * 10 > 9)
|
if(Math.random() * 10 > 9)
|
||||||
|
@ -24,6 +24,7 @@ import com.gmail.nossr50.Users;
|
|||||||
import com.gmail.nossr50.m;
|
import com.gmail.nossr50.m;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.mcPermissions;
|
import com.gmail.nossr50.mcPermissions;
|
||||||
|
import com.gmail.nossr50.command.Commands;
|
||||||
import com.gmail.nossr50.config.LoadProperties;
|
import com.gmail.nossr50.config.LoadProperties;
|
||||||
import com.gmail.nossr50.contrib.SpoutStuff;
|
import com.gmail.nossr50.contrib.SpoutStuff;
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||||
@ -112,7 +113,7 @@ public class mcPlayerListener extends PlayerListener
|
|||||||
player.sendMessage(mcLocale.getString("mcPlayerListener.MOTD", new Object[] {plugin.getDescription().getVersion(), LoadProperties.mcmmo}));
|
player.sendMessage(mcLocale.getString("mcPlayerListener.MOTD", new Object[] {plugin.getDescription().getVersion(), LoadProperties.mcmmo}));
|
||||||
player.sendMessage(mcLocale.getString("mcPlayerListener.WIKI"));
|
player.sendMessage(mcLocale.getString("mcPlayerListener.WIKI"));
|
||||||
}
|
}
|
||||||
if(plugin.xpevent)
|
if(Commands.xpevent)
|
||||||
player.sendMessage(ChatColor.GOLD+"mcMMO is currently in an XP rate event! XP rate is "+LoadProperties.xpGainMultiplier+"x!");
|
player.sendMessage(ChatColor.GOLD+"mcMMO is currently in an XP rate event! XP rate is "+LoadProperties.xpGainMultiplier+"x!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,8 +125,6 @@ public class mcPlayerListener extends PlayerListener
|
|||||||
Action action = event.getAction();
|
Action action = event.getAction();
|
||||||
Block block = event.getClickedBlock();
|
Block block = event.getClickedBlock();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Archery Nerf
|
//Archery Nerf
|
||||||
if(player.getItemInHand().getTypeId() == 261 && LoadProperties.archeryFireRateLimit)
|
if(player.getItemInHand().getTypeId() == 261 && LoadProperties.archeryFireRateLimit)
|
||||||
{
|
{
|
||||||
@ -179,12 +178,12 @@ public class mcPlayerListener extends PlayerListener
|
|||||||
boolean pass = false;
|
boolean pass = false;
|
||||||
if(Herbalism.hasSeeds(player) && mcPermissions.getInstance().herbalism(player)){
|
if(Herbalism.hasSeeds(player) && mcPermissions.getInstance().herbalism(player)){
|
||||||
Herbalism.removeSeeds(player);
|
Herbalism.removeSeeds(player);
|
||||||
if(LoadProperties.enableCobbleToMossy && m.blockBreakSimulate(block, player, plugin) && block.getType() == Material.COBBLESTONE && Math.random() * 1500 <= PP.getSkillLevel(SkillType.HERBALISM)){
|
if(LoadProperties.enableCobbleToMossy && m.blockBreakSimulate(block, player) && block.getType() == Material.COBBLESTONE && Math.random() * 1500 <= PP.getSkillLevel(SkillType.HERBALISM)){
|
||||||
player.sendMessage(mcLocale.getString("mcPlayerListener.GreenThumb"));
|
player.sendMessage(mcLocale.getString("mcPlayerListener.GreenThumb"));
|
||||||
block.setType(Material.MOSSY_COBBLESTONE);
|
block.setType(Material.MOSSY_COBBLESTONE);
|
||||||
pass = true;
|
pass = true;
|
||||||
}
|
}
|
||||||
if(block.getType() == Material.DIRT && m.blockBreakSimulate(block, player, plugin) && Math.random() * 1500 <= PP.getSkillLevel(SkillType.HERBALISM)){
|
if(block.getType() == Material.DIRT && m.blockBreakSimulate(block, player) && Math.random() * 1500 <= PP.getSkillLevel(SkillType.HERBALISM)){
|
||||||
player.sendMessage(mcLocale.getString("mcPlayerListener.GreenThumb"));
|
player.sendMessage(mcLocale.getString("mcPlayerListener.GreenThumb"));
|
||||||
block.setType(Material.GRASS);
|
block.setType(Material.GRASS);
|
||||||
pass = true;
|
pass = true;
|
||||||
|
@ -4,16 +4,10 @@ import org.getspout.spoutapi.event.spout.SpoutCraftEnableEvent;
|
|||||||
import org.getspout.spoutapi.event.spout.SpoutListener;
|
import org.getspout.spoutapi.event.spout.SpoutListener;
|
||||||
import org.getspout.spoutapi.gui.GenericTexture;
|
import org.getspout.spoutapi.gui.GenericTexture;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.contrib.SpoutStuff;
|
import com.gmail.nossr50.contrib.SpoutStuff;
|
||||||
|
|
||||||
public class mcSpoutListener extends SpoutListener
|
public class mcSpoutListener extends SpoutListener
|
||||||
{
|
{
|
||||||
mcMMO plugin = null;
|
|
||||||
public mcSpoutListener(mcMMO pluginx)
|
|
||||||
{
|
|
||||||
plugin = pluginx;
|
|
||||||
}
|
|
||||||
public void onSpoutCraftEnable(SpoutCraftEnableEvent event)
|
public void onSpoutCraftEnable(SpoutCraftEnableEvent event)
|
||||||
{
|
{
|
||||||
if(event.getPlayer().isSpoutCraftEnabled())
|
if(event.getPlayer().isSpoutCraftEnabled())
|
||||||
|
@ -5,13 +5,12 @@ import java.io.FileReader;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
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.*;
|
import org.bukkit.entity.*;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.config.*;
|
import com.gmail.nossr50.config.*;
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.FakeBlockBreakEvent;
|
import com.gmail.nossr50.datatypes.FakeBlockBreakEvent;
|
||||||
@ -110,11 +109,11 @@ public class m
|
|||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean blockBreakSimulate(Block block, Player player, Plugin plugin)
|
public static boolean blockBreakSimulate(Block block, Player player)
|
||||||
{
|
{
|
||||||
FakeBlockBreakEvent event = new FakeBlockBreakEvent(block, player);
|
FakeBlockBreakEvent event = new FakeBlockBreakEvent(block, player);
|
||||||
if(block != null && plugin != null && player != null){
|
if(block != null && player != null){
|
||||||
plugin.getServer().getPluginManager().callEvent(event);
|
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||||
if(!event.isCancelled())
|
if(!event.isCancelled())
|
||||||
{
|
{
|
||||||
return true; //Return true if not cancelled
|
return true; //Return true if not cancelled
|
||||||
@ -307,7 +306,7 @@ public class m
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static void convertToMySQL(Plugin pluginx)
|
public static void convertToMySQL()
|
||||||
{
|
{
|
||||||
if(!LoadProperties.useMySQL)
|
if(!LoadProperties.useMySQL)
|
||||||
return;
|
return;
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -11,6 +11,7 @@ import java.io.ObjectOutputStream;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.Users;
|
import com.gmail.nossr50.Users;
|
||||||
@ -78,9 +79,9 @@ public class Party
|
|||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void informPartyMembers(Player player) {
|
public void informPartyMembers(Player player)
|
||||||
Player[] players = plugin.getPlayersOnline();
|
{
|
||||||
informPartyMembers(player, players);
|
informPartyMembers(player, Bukkit.getServer().getOnlinePlayers());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -102,8 +103,7 @@ public class Party
|
|||||||
|
|
||||||
public void informPartyMembersOwnerChange(String newOwner) {
|
public void informPartyMembersOwnerChange(String newOwner) {
|
||||||
Player newOwnerPlayer = plugin.getServer().getPlayer(newOwner);
|
Player newOwnerPlayer = plugin.getServer().getPlayer(newOwner);
|
||||||
Player[] players = plugin.getPlayersOnline();
|
informPartyMembersOwnerChange(newOwnerPlayer, Bukkit.getServer().getOnlinePlayers());
|
||||||
informPartyMembersOwnerChange(newOwnerPlayer, players);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void informPartyMembersOwnerChange(Player newOwner, Player[] players) {
|
public void informPartyMembersOwnerChange(Player newOwner, Player[] players) {
|
||||||
@ -120,9 +120,9 @@ public class Party
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void informPartyMembersQuit(Player player) {
|
public void informPartyMembersQuit(Player player)
|
||||||
Player[] players = plugin.getPlayersOnline();
|
{
|
||||||
informPartyMembersQuit(player, players);
|
informPartyMembersQuit(player, Bukkit.getServer().getOnlinePlayers());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void informPartyMembersQuit(Player player, Player[] players)
|
public void informPartyMembersQuit(Player player, Player[] players)
|
||||||
|
Loading…
Reference in New Issue
Block a user