mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-27 19:24:44 +02:00
Reworked some Spout stuff
among other things
This commit is contained in:
@ -16,6 +16,7 @@ import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.spout.SpoutStuff;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class McremoveCommand implements CommandExecutor {
|
||||
@ -102,10 +103,12 @@ public class McremoveCommand implements CommandExecutor {
|
||||
PlayerProfile playerProfile = Users.getProfile(player);
|
||||
|
||||
if (playerProfile != null) {
|
||||
playerProfile.getSpoutHud().removeWidgets();
|
||||
Users.remove(player.getName());
|
||||
|
||||
if (player.isOnline()) {
|
||||
Users.addUser((Player) player);
|
||||
SpoutStuff.reloadSpoutPlayer((Player) player);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,20 +9,13 @@ import org.bukkit.entity.Player;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.config.SpoutConfig;
|
||||
import com.gmail.nossr50.datatypes.HUDType;
|
||||
import com.gmail.nossr50.datatypes.HUDmmo;
|
||||
import com.gmail.nossr50.datatypes.HudType;
|
||||
import com.gmail.nossr50.datatypes.SpoutHud;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.spout.SpoutStuff;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class MchudCommand implements CommandExecutor {
|
||||
private final mcMMO plugin;
|
||||
|
||||
public MchudCommand (mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
String usage = ChatColor.RED + "Proper usage is /mchud <hud-type>"; //TODO: Locale
|
||||
@ -40,33 +33,24 @@ public class MchudCommand implements CommandExecutor {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
HUDType hud;
|
||||
PlayerProfile playerProfile = Users.getProfile(player);
|
||||
|
||||
if (args[0].equalsIgnoreCase("disabled")) {
|
||||
hud = HUDType.DISABLED;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("standard")) {
|
||||
hud = HUDType.STANDARD;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("small")) {
|
||||
hud = HUDType.SMALL;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("retro")) {
|
||||
hud = HUDType.RETRO;
|
||||
}
|
||||
else {
|
||||
player.sendMessage(invalid);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (SpoutStuff.playerHUDs.containsKey(player)) {
|
||||
SpoutStuff.playerHUDs.get(player).resetHUD();
|
||||
SpoutStuff.playerHUDs.remove(player);
|
||||
PP.setHUDType(hud);
|
||||
SpoutStuff.playerHUDs.put(player, new HUDmmo(player, plugin));
|
||||
for (HudType hudType : HudType.values()) {
|
||||
if (hudType.toString().equalsIgnoreCase(args[0])) {
|
||||
playerProfile.setHudType(hudType);
|
||||
|
||||
SpoutHud spoutHud = playerProfile.getSpoutHud();
|
||||
|
||||
if (spoutHud != null) {
|
||||
spoutHud.initializeXpBar();
|
||||
spoutHud.updateXpBar();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
player.sendMessage(invalid);
|
||||
return true;
|
||||
|
||||
default:
|
||||
|
@ -13,7 +13,6 @@ import com.gmail.nossr50.config.SpoutConfig;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.spout.SpoutStuff;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
@ -34,49 +33,48 @@ public class XplockCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
PlayerProfile playerProfile = Users.getProfile(player);
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (PP.getXpBarLocked()) {
|
||||
PP.toggleXpBarLocked();
|
||||
if (playerProfile.getXpBarLocked()) {
|
||||
playerProfile.toggleXpBarLocked();
|
||||
player.sendMessage(LocaleLoader.getString("Commands.xplock.unlocked"));
|
||||
return true;
|
||||
}
|
||||
|
||||
SkillType lastGained = PP.getLastGained();
|
||||
SkillType lastGained = playerProfile.getLastGained();
|
||||
|
||||
if (lastGained != null) {
|
||||
PP.toggleXpBarLocked();
|
||||
PP.setSkillLock(lastGained);
|
||||
playerProfile.toggleXpBarLocked();
|
||||
playerProfile.setSkillLock(lastGained);
|
||||
player.sendMessage(LocaleLoader.getString("Commands.xplock.locked", new Object[] { Misc.getCapitalized(lastGained.toString()) }));
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
player.sendMessage(usage);
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (Skills.isSkill(args[0])) {
|
||||
if (Permissions.getInstance().permission(player, "mcmmo.skills." + args[0].toLowerCase())) {
|
||||
PP.setXpBarLocked(true);
|
||||
PP.setSkillLock(Skills.getSkillType(args[0]));
|
||||
SpoutStuff.updateXpBar(player);
|
||||
playerProfile.setXpBarLocked(true);
|
||||
playerProfile.setSkillLock(Skills.getSkillType(args[0]));
|
||||
playerProfile.updateXpBar();
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.xplock.locked", new Object[] { Misc.getCapitalized(args[0]) }));
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
player.sendMessage(usage);
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user