From 1429cc0a48526d2603f3b6bdf600ff6eb9d027c3 Mon Sep 17 00:00:00 2001 From: sandtechnology Date: Sun, 12 Apr 2020 12:09:13 +0800 Subject: [PATCH] Fix change shop owner command showed previous owner issue Former-commit-id: ef9627eeb576063665b4248c711c99be7d8588dc --- .../subcommand/SubCommand_SetOwner.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/maxgamer/quickshop/command/subcommand/SubCommand_SetOwner.java b/src/main/java/org/maxgamer/quickshop/command/subcommand/SubCommand_SetOwner.java index 27ea96c47..319ee73a5 100644 --- a/src/main/java/org/maxgamer/quickshop/command/subcommand/SubCommand_SetOwner.java +++ b/src/main/java/org/maxgamer/quickshop/command/subcommand/SubCommand_SetOwner.java @@ -19,19 +19,20 @@ package org.maxgamer.quickshop.command.subcommand; -import java.util.ArrayList; -import java.util.List; import org.bukkit.OfflinePlayer; import org.bukkit.block.Block; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.util.BlockIterator; import org.jetbrains.annotations.NotNull; -import org.maxgamer.quickshop.command.CommandProcesser; import org.maxgamer.quickshop.QuickShop; +import org.maxgamer.quickshop.command.CommandProcesser; import org.maxgamer.quickshop.shop.Shop; import org.maxgamer.quickshop.util.MsgUtil; +import java.util.ArrayList; +import java.util.List; + public class SubCommand_SetOwner implements CommandProcesser { private final QuickShop plugin = QuickShop.instance; @@ -64,16 +65,15 @@ public class SubCommand_SetOwner implements CommandProcesser { continue; } - @SuppressWarnings("deprecation") final OfflinePlayer p = plugin.getServer().getOfflinePlayer(cmdArg[0]); - final String shopOwner = plugin.getServer().getOfflinePlayer(shop.getOwner()).getName(); - if (shopOwner == null) { - MsgUtil.sendMessage(sender,MsgUtil.getMessage("unknown-player", null)); + @SuppressWarnings("deprecation") final OfflinePlayer newShopOwner = plugin.getServer().getOfflinePlayer(cmdArg[0]); + if (newShopOwner.getName() == null) { + MsgUtil.sendMessage(sender, MsgUtil.getMessage("unknown-player", null)); return; } - shop.setOwner(p.getUniqueId()); + shop.setOwner(newShopOwner.getUniqueId()); // shop.setSignText(); shop.update(); - MsgUtil.sendMessage(sender,MsgUtil.getMessage("command.new-owner", sender, shopOwner)); + MsgUtil.sendMessage(sender, MsgUtil.getMessage("command.new-owner", sender, newShopOwner.getName())); return; }