Skip to content

Commit

Permalink
Don't show gamemode change on join
Browse files Browse the repository at this point in the history
  • Loading branch information
Frank Baumann committed May 14, 2014
1 parent 7003675 commit 2f258c8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: ManagerXL
version: 0.1
version: 0.3
main: com.dre.managerxl.P
authors: [Frank Baumann, Tobias Schmitz, Joscha Schmitz]
softdepend: [Vault]
Expand Down
8 changes: 5 additions & 3 deletions src/com/dre/managerxl/MPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public static boolean LoadAsYml(File file) {
mPlayer.setMuted(ymlFile.getBoolean(uuid + ".isMuted"));

/* GameMode */
mPlayer.setGameMode(GameMode.valueOf(ymlFile.getString(uuid + ".GameMode")));
mPlayer.setGameMode(GameMode.valueOf(ymlFile.getString(uuid + ".GameMode")), false);

/* Location */
if (ymlFile.contains(uuid + ".home")) {
Expand Down Expand Up @@ -262,13 +262,15 @@ public GameMode getGameMode() {
return gameMode;
}

public boolean setGameMode(GameMode gameMode) {
public boolean setGameMode(GameMode gameMode, boolean msg) {
if (gameMode != null) {
this.gameMode = gameMode;

if (this.getPlayer() != null) {
this.getPlayer().setGameMode(this.gameMode);
P.p.msg(this.getPlayer(), P.p.getLanguageReader().get("Player_GameModeChanged", this.gameMode.name()));
if (msg) {
P.p.msg(this.getPlayer(), P.p.getLanguageReader().get("Player_GameModeChanged", this.gameMode.name()));
}
}

return true;
Expand Down
10 changes: 5 additions & 5 deletions src/com/dre/managerxl/commands/player/CMDGameMode.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@ public void onExecute(String[] args, CommandSender sender) {
if (player.getPlayer() != null) {
if (args.length < 1) {
if (player.getGameMode() == GameMode.CREATIVE) {
player.setGameMode(GameMode.SURVIVAL);
player.setGameMode(GameMode.SURVIVAL, true);
} else {
player.setGameMode(GameMode.CREATIVE);
player.setGameMode(GameMode.CREATIVE, true);
}
} else {
MPlayer targetPlayer = MPlayer.getFromName(args[0]);
if (targetPlayer != null) {
if (args.length < 2) {
if (targetPlayer.getGameMode() == GameMode.CREATIVE) {
targetPlayer.setGameMode(GameMode.SURVIVAL);
targetPlayer.setGameMode(GameMode.SURVIVAL, true);
} else {
targetPlayer.setGameMode(GameMode.CREATIVE);
targetPlayer.setGameMode(GameMode.CREATIVE, true);
}

if (targetPlayer != player) {
Expand All @@ -66,7 +66,7 @@ public void onExecute(String[] args, CommandSender sender) {
if(gm == 2 || gmString.equalsIgnoreCase("adventure"))
gameMode = GameMode.ADVENTURE;

if (targetPlayer.setGameMode(gameMode)) {
if (targetPlayer.setGameMode(gameMode, true)) {
if (targetPlayer != player) {
P.p.msg(sender, P.p.getLanguageReader().get("Player_TargetGameModeChanged", targetPlayer.getGameMode().name(), args[0]));
}
Expand Down
2 changes: 1 addition & 1 deletion src/com/dre/managerxl/listeners/PlayerListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void onPlayerJoin(PlayerJoinEvent event) {
MPlayer player = MPlayer.getOrCreate(event.getPlayer().getUniqueId());

player.setOnline(true);
player.setGameMode(player.getGameMode());
player.setGameMode(player.getGameMode(), false);

// Set invisible Players
if (!player.isVisible()) {
Expand Down

0 comments on commit 2f258c8

Please sign in to comment.