mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-12-24 17:47:44 +01:00
Bug fixes, among other things.
This commit is contained in:
parent
4e1d07df12
commit
3695b55f38
@ -1,8 +1,13 @@
|
||||
package com.bukkit.nossr50.mcMMO;
|
||||
|
||||
import com.nijikokun.bukkit.Permissions.Permissions;
|
||||
import com.nijiko.Messaging;
|
||||
import com.nijiko.permissions.PermissionHandler;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.event.Event.Priority;
|
||||
@ -15,11 +20,13 @@ import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class mcMMO extends JavaPlugin {
|
||||
public static final Logger log = Logger.getLogger("Minecraft");
|
||||
private final mcPlayerListener playerListener = new mcPlayerListener(this);
|
||||
private final mcBlockListener blockListener = new mcBlockListener(this);
|
||||
private final mcEntityListener entityListener = new mcEntityListener(this);
|
||||
private final HashMap<Player, Boolean> debugees = new HashMap<Player, Boolean>();
|
||||
private final String name = "mcMMO";
|
||||
public static PermissionHandler Permissions = null;
|
||||
|
||||
public mcMMO(PluginLoader pluginLoader, Server instance, PluginDescriptionFile desc, File folder, File plugin, ClassLoader cLoader) {
|
||||
super(pluginLoader, instance, desc, folder, plugin, cLoader);
|
||||
@ -43,6 +50,19 @@ public class mcMMO extends JavaPlugin {
|
||||
PluginDescriptionFile pdfFile = this.getDescription();
|
||||
System.out.println( pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!" );
|
||||
}
|
||||
public void setupPermissions() {
|
||||
Plugin test = this.getServer().getPluginManager().getPlugin("Permissions");
|
||||
|
||||
|
||||
if(this.Permissions == null) {
|
||||
if(test != null) {
|
||||
this.Permissions = ((Permissions)test).getHandler();
|
||||
} else {
|
||||
log.info(Messaging.bracketize(name) + " Permission system not enabled. Disabling plugin.");
|
||||
this.getServer().getPluginManager().disablePlugin(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void onDisable() {
|
||||
System.out.println("mcMMO disabled.");
|
||||
}
|
||||
|
@ -12,20 +12,55 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class mcPlayerListener extends PlayerListener {
|
||||
public Location spawn = null;
|
||||
private static mcMMO plugin;
|
||||
private mcMMO plugin;
|
||||
|
||||
public mcPlayerListener(mcMMO instance) {
|
||||
plugin = instance;
|
||||
}
|
||||
private static volatile mcPlayerListener instance;
|
||||
public static mcPlayerListener getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new mcPlayerListener(plugin);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
public Player[] getPlayersOnline() {
|
||||
return plugin.getServer().getOnlinePlayers();
|
||||
}
|
||||
public boolean isPlayer(String playerName){
|
||||
for(Player herp : getPlayersOnline()){
|
||||
if(herp.getName().toLowerCase().equals(playerName.toLowerCase())){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public Player getPlayer(String playerName){
|
||||
for(Player herp : getPlayersOnline()){
|
||||
if(herp.getName().toLowerCase().equals(playerName.toLowerCase())){
|
||||
return herp;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public int partyCount(Player player){
|
||||
int x = 0;
|
||||
for(Player hurrdurr: getPlayersOnline()){
|
||||
if(mcUsers.getProfile(player).getParty().equals(mcUsers.getProfile(hurrdurr).getParty()))
|
||||
x++;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
public void informPartyMembers(Player player){
|
||||
int x = 0;
|
||||
for(Player p : getPlayersOnline()){
|
||||
if(mcm.getInstance().inSameParty(player, p) && !p.getName().equals(player.getName())){
|
||||
p.sendMessage(player.getName() + ChatColor.GREEN + " has joined your party");
|
||||
x++;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void informPartyMembersQuit(Player player){
|
||||
int x = 0;
|
||||
for(Player p : getPlayersOnline()){
|
||||
if(mcm.getInstance().inSameParty(player, p) && !p.getName().equals(player.getName())){
|
||||
p.sendMessage(player.getName() + ChatColor.GREEN + " has left your party");
|
||||
x++;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void onPlayerJoin(PlayerEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
@ -58,6 +93,9 @@ public class mcPlayerListener extends PlayerListener {
|
||||
*/
|
||||
}
|
||||
}
|
||||
/*
|
||||
* TOOLS
|
||||
*/
|
||||
if(mcm.getInstance().isTools(is) && block.getTypeId() == 42){
|
||||
if(mcm.getInstance().isIronTools(is) && mcm.getInstance().hasIron(player)){
|
||||
is.setDurability(mcm.getInstance().getToolRepairAmount(is, durability, player));
|
||||
@ -72,9 +110,9 @@ public class mcPlayerListener extends PlayerListener {
|
||||
} else if (mcm.getInstance().isDiamondTools(is) && mcUsers.getProfile(player).getRepairInt() < 50){
|
||||
player.sendMessage(ChatColor.DARK_RED +"You're not adept enough to repair Diamond");
|
||||
} else if (mcm.getInstance().isDiamondTools(is) && !mcm.getInstance().hasDiamond(player) || mcm.getInstance().isIronTools(is) && !mcm.getInstance().hasIron(player)){
|
||||
if(!mcm.getInstance().hasDiamond(player))
|
||||
if(mcm.getInstance().isDiamondTools(is) && !mcm.getInstance().hasDiamond(player))
|
||||
player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.BLUE+ "Diamonds");
|
||||
if(!mcm.getInstance().hasIron(player))
|
||||
if(mcm.getInstance().isIronTools(is) && !mcm.getInstance().hasIron(player))
|
||||
player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.GRAY+ "Iron");
|
||||
} else if (mcm.getInstance().isDiamondArmor(is) && !mcm.getInstance().hasDiamond(player)){
|
||||
player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.BLUE+ "Diamonds");
|
||||
@ -86,7 +124,173 @@ public class mcPlayerListener extends PlayerListener {
|
||||
public void onPlayerCommand(PlayerChatEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
String[] split = event.getMessage().split(" ");
|
||||
mcc.getInstance().CommandCheck(player, split, spawn);
|
||||
String playerName = player.getName();
|
||||
if(split[0].equalsIgnoreCase("/mcmmo")){
|
||||
player.sendMessage(ChatColor.GRAY+"mcMMO is an RPG inspired plugin");
|
||||
player.sendMessage(ChatColor.GRAY+"You can gain skills in several professions by");
|
||||
player.sendMessage(ChatColor.GRAY+"doing things related to that profession.");
|
||||
player.sendMessage(ChatColor.GRAY+"Mining for example will increase your mining XP.");
|
||||
player.sendMessage(ChatColor.GRAY+"Wood Cutting will increase Wood Cutting, etc...");
|
||||
player.sendMessage(ChatColor.GRAY+"Repairing is simple in mcMMO");
|
||||
player.sendMessage(ChatColor.GRAY+"Say you want to repair an iron shovel");
|
||||
player.sendMessage(ChatColor.GRAY+"start by making an anvil by combining 9 iron ingots");
|
||||
player.sendMessage(ChatColor.GRAY+"on a workbench. Place the anvil and while holding the shovel");
|
||||
player.sendMessage(ChatColor.GRAY+"right click the anvil interact with it, If you have spare");
|
||||
player.sendMessage(ChatColor.GRAY+"iron ingots in your inventory the item will be repaired.");
|
||||
player.sendMessage(ChatColor.GRAY+"You cannot hurt other party members");
|
||||
player.sendMessage(ChatColor.BLUE+"Set your own spawn with "+ChatColor.RED+"/myspawn");
|
||||
player.sendMessage(ChatColor.GREEN+"Based on your skills you will get "+ChatColor.DARK_RED+"random procs "+ChatColor.GREEN+ "when");
|
||||
player.sendMessage(ChatColor.GREEN+"using your profession, like "+ChatColor.DARK_RED+"double drops "+ChatColor.GREEN+"or "+ChatColor.DARK_RED+"better repairs");
|
||||
player.sendMessage(ChatColor.GREEN+"Find out mcMMO commands with /mcc");
|
||||
}
|
||||
if(split[0].equalsIgnoreCase("/mcc")){
|
||||
player.sendMessage(ChatColor.GRAY+"mcMMO has a party system included");
|
||||
player.sendMessage(ChatColor.GREEN+"~~Commands~~");
|
||||
player.sendMessage(ChatColor.GRAY+"/party <name> - to join a party");
|
||||
player.sendMessage(ChatColor.GRAY+"/party q - to quit a party");
|
||||
player.sendMessage(ChatColor.GRAY+"/ptp <name> - party teleport");
|
||||
player.sendMessage(ChatColor.GRAY+"/p - toggles party chat");
|
||||
player.sendMessage(ChatColor.GRAY+"/setmyspawn - set your own spawn location");
|
||||
player.sendMessage(ChatColor.GRAY+"/myspawn - travel to myspawn, clears inventory");
|
||||
player.sendMessage(ChatColor.GRAY+"/setspawn - Server ops can designate a 'spawn'");
|
||||
player.sendMessage(ChatColor.GRAY+"/spawn - Travel to the op designated spawn");
|
||||
player.sendMessage(ChatColor.GRAY+"/whois - view detailed info about a player (req op)");
|
||||
}
|
||||
if(mcUsers.getProfile(player).inParty() && split[0].equalsIgnoreCase("/ptp")){
|
||||
if(split.length < 2){
|
||||
player.sendMessage(ChatColor.RED+"Usage is /ptp <playername>");
|
||||
return;
|
||||
}
|
||||
if(isPlayer(split[1])){
|
||||
Player target = getPlayer(split[1]);
|
||||
if(mcUsers.getProfile(player).getParty().equals(mcUsers.getProfile(target).getParty())){
|
||||
player.teleportTo(target);
|
||||
player.sendMessage(ChatColor.GREEN+"You have teleported to "+target.getName());
|
||||
target.sendMessage(ChatColor.GREEN+player.getName() + " has teleported to you.");
|
||||
}
|
||||
}
|
||||
}
|
||||
if(player.isOp() && split[0].equalsIgnoreCase("/whois")){
|
||||
if(split.length < 2){
|
||||
player.sendMessage(ChatColor.RED + "Proper usage is /whois <playername>");
|
||||
return;
|
||||
}
|
||||
//if split[1] is a player
|
||||
if(isPlayer(split[1])){
|
||||
Player target = getPlayer(split[1]);
|
||||
double x,y,z;
|
||||
x = target.getLocation().getX();
|
||||
y = target.getLocation().getY();
|
||||
z = target.getLocation().getZ();
|
||||
player.sendMessage(ChatColor.GREEN + "~~WHOIS RESULTS~~");
|
||||
player.sendMessage(target.getName());
|
||||
if(mcUsers.getProfile(target).inParty())
|
||||
player.sendMessage("Party: "+mcUsers.getProfile(target).getParty());
|
||||
player.sendMessage("Health: "+target.getHealth()+ChatColor.GRAY+" (20 is full health)");
|
||||
player.sendMessage("OP: " + target.isOp());
|
||||
player.sendMessage(ChatColor.GREEN+"~~mcMMO stats~~");
|
||||
player.sendMessage("Mining Skill: "+mcUsers.getProfile(target).getMining());
|
||||
player.sendMessage("Repair Skill: "+mcUsers.getProfile(target).getRepair());
|
||||
player.sendMessage("Woodcutting Skill: "+mcUsers.getProfile(target).getWoodCutting());
|
||||
player.sendMessage(ChatColor.GREEN+"~~COORDINATES~~");
|
||||
player.sendMessage("X: "+x);
|
||||
player.sendMessage("Y: "+y);
|
||||
player.sendMessage("Z: "+z);
|
||||
}
|
||||
}
|
||||
if(split[0].equalsIgnoreCase("/setmyspawn")){
|
||||
double x = player.getLocation().getX();
|
||||
double y = player.getLocation().getY();
|
||||
double z = player.getLocation().getZ();
|
||||
mcUsers.getProfile(player).setMySpawn(x, y, z);
|
||||
player.sendMessage(ChatColor.DARK_AQUA + "Myspawn has been set to your current location.");
|
||||
}
|
||||
if(player.isOp() && split[0].equalsIgnoreCase("/setspawn")){
|
||||
spawn = player.getLocation();
|
||||
player.sendMessage("Spawn set to current location");
|
||||
}
|
||||
if(split[0].equalsIgnoreCase("/stats")){
|
||||
player.sendMessage(ChatColor.DARK_GREEN + "mcMMO stats");
|
||||
player.sendMessage(ChatColor.DARK_GREEN + "Mining Skill: " + mcUsers.getProfile(player).getMining());
|
||||
player.sendMessage(ChatColor.DARK_GREEN + "Repair Skill: " + mcUsers.getProfile(player).getRepair());
|
||||
player.sendMessage(ChatColor.DARK_GREEN + "Woodcutting Skill: "+mcUsers.getProfile(player).getWoodCutting());
|
||||
player.sendMessage(ChatColor.GRAY + "Increases depending on the material you mine");
|
||||
}
|
||||
//Party command
|
||||
if(split[0].equalsIgnoreCase("/party")){
|
||||
if(split.length == 1 && !mcUsers.getProfile(player).inParty()){
|
||||
player.sendMessage("Proper usage is /party <name> or 'q' to quit");
|
||||
return;
|
||||
}
|
||||
if(split.length == 1 && mcUsers.getProfile(player).inParty()){
|
||||
String tempList = "";
|
||||
int x = 0;
|
||||
for(Player p : plugin.getServer().getOnlinePlayers())
|
||||
{
|
||||
if(mcUsers.getProfile(player).getParty().equals(mcUsers.getProfile(p).getParty())){
|
||||
if(p != null && x+1 >= partyCount(player)){
|
||||
tempList+= p.getName();
|
||||
x++;
|
||||
}
|
||||
if(p != null && x < partyCount(player)){
|
||||
tempList+= p.getName() +", ";
|
||||
x++;
|
||||
}
|
||||
}
|
||||
}
|
||||
player.sendMessage(ChatColor.GREEN+"You are in party \""+mcUsers.getProfile(player).getParty()+"\"");
|
||||
player.sendMessage(ChatColor.GREEN + "Party Members ("+ChatColor.WHITE+tempList+ChatColor.GREEN+")");
|
||||
}
|
||||
if(split.length > 1 && split[1].equals("q") && mcUsers.getProfile(player).inParty()){
|
||||
informPartyMembersQuit(player);
|
||||
mcUsers.getProfile(player).removeParty();
|
||||
player.sendMessage(ChatColor.RED + "You have left that party");
|
||||
return;
|
||||
}
|
||||
if(split.length >= 2){
|
||||
mcUsers.getProfile(player).setParty(split[1]);
|
||||
player.sendMessage("Joined Party: " + split[1]);
|
||||
informPartyMembers(player);
|
||||
}
|
||||
}
|
||||
if(split[0].equalsIgnoreCase("/p")){
|
||||
if(mcConfig.getInstance().isAdminToggled(player.getName()))
|
||||
mcConfig.getInstance().toggleAdminChat(playerName);
|
||||
mcConfig.getInstance().togglePartyChat(playerName);
|
||||
if(mcConfig.getInstance().isPartyToggled(playerName)){
|
||||
player.sendMessage(ChatColor.GREEN + "Party Chat Toggled On");
|
||||
} else {
|
||||
player.sendMessage(ChatColor.GREEN + "Party Chat Toggled " + ChatColor.RED + "Off");
|
||||
}
|
||||
}
|
||||
if(split[0].equalsIgnoreCase("/a") && player.isOp()){
|
||||
if(mcConfig.getInstance().isPartyToggled(player.getName()))
|
||||
mcConfig.getInstance().togglePartyChat(playerName);
|
||||
mcConfig.getInstance().toggleAdminChat(playerName);
|
||||
if(mcConfig.getInstance().isAdminToggled(playerName)){
|
||||
player.sendMessage(ChatColor.AQUA + "Admin chat toggled " + ChatColor.GREEN + "On");
|
||||
} else {
|
||||
player.sendMessage(ChatColor.AQUA + "Admin chat toggled " + ChatColor.RED + "Off");
|
||||
}
|
||||
}
|
||||
if(split[0].equalsIgnoreCase("/myspawn")){
|
||||
if(mcUsers.getProfile(player).getMySpawn(player) != null){
|
||||
player.getInventory().clear();
|
||||
player.setHealth(20);
|
||||
player.teleportTo(mcUsers.getProfile(player).getMySpawn(player));
|
||||
player.sendMessage("Inventory cleared & health restored");
|
||||
}else{
|
||||
player.sendMessage(ChatColor.RED+"Configure your myspawn first with /setmyspawn");
|
||||
}
|
||||
}
|
||||
if(split[0].equalsIgnoreCase("/spawn")){
|
||||
if(spawn != null){
|
||||
player.teleportTo(spawn);
|
||||
player.sendMessage("Welcome to spawn, home of the feeble.");
|
||||
return;
|
||||
}
|
||||
player.sendMessage("Spawn isn't configured. Have an OP set it with /setspawn");
|
||||
}
|
||||
}
|
||||
public void onPlayerChat(PlayerChatEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
@ -97,7 +301,7 @@ public class mcPlayerListener extends PlayerListener {
|
||||
event.setCancelled(true);
|
||||
for(Player herp : plugin.getServer().getOnlinePlayers()){
|
||||
if(mcUsers.getProfile(herp).inParty()){
|
||||
if(mcm.inSameParty(herp, player)){
|
||||
if(mcm.getInstance().inSameParty(herp, player)){
|
||||
herp.sendMessage(x+event.getMessage());
|
||||
}
|
||||
}
|
||||
|
@ -15,58 +15,13 @@ public class mcm {
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public boolean isPlayer(String playerName){
|
||||
for(Player herp : mcPlayerListener.getInstance().getPlayersOnline()){
|
||||
if(herp.getName().toLowerCase().equals(playerName.toLowerCase())){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public int partyCount(Player player){
|
||||
Player players[] = mcPlayerListener.getInstance().getPlayersOnline();
|
||||
int x = 0;
|
||||
for(Player hurrdurr: players){
|
||||
if(mcUsers.getProfile(player).getParty().equals(mcUsers.getProfile(hurrdurr).getParty()))
|
||||
x++;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
public static void informPartyMembers(Player player){
|
||||
int x = 0;
|
||||
for(Player p : mcPlayerListener.getInstance().getPlayersOnline()){
|
||||
if(inSameParty(player, p) && !p.getName().equals(player.getName())){
|
||||
p.sendMessage(player.getName() + ChatColor.GREEN + " has joined your party");
|
||||
x++;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void informPartyMembersQuit(Player player){
|
||||
int x = 0;
|
||||
for(Player p : mcPlayerListener.getInstance().getPlayersOnline()){
|
||||
if(inSameParty(player, p) && !p.getName().equals(player.getName())){
|
||||
p.sendMessage(player.getName() + ChatColor.GREEN + " has left your party");
|
||||
x++;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static boolean inSameParty(Player playera, Player playerb){
|
||||
public boolean inSameParty(Player playera, Player playerb){
|
||||
if(mcUsers.getProfile(playera).getParty().equals(mcUsers.getProfile(playerb).getParty())){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public Player getPlayer(String playerName){
|
||||
for(Player herp : mcPlayerListener.getInstance().getPlayersOnline()){
|
||||
if(herp.getName().toLowerCase().equals(playerName.toLowerCase())){
|
||||
return herp;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public boolean checkPlayerProcRepair(Player player){
|
||||
if(mcUsers.getProfile(player).getRepairInt() >= 750){
|
||||
if(Math.random() * 10 > 2){
|
||||
|
@ -1,3 +1,3 @@
|
||||
name: mcMMO
|
||||
main: com.bukkit.nossr50.mcMMO.mcMMO
|
||||
version: 0.2
|
||||
version: 0.2.1
|
Loading…
Reference in New Issue
Block a user