-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a deleteplayer command to delete the account of a player
- Loading branch information
Showing
5 changed files
with
82 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/main/java/ad1tya2/adiauth/Bungee/commands/deleteplayer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package ad1tya2.adiauth.Bungee.commands; | ||
|
||
import ad1tya2.adiauth.Bungee.UserProfile; | ||
import ad1tya2.adiauth.Bungee.data.storage; | ||
import net.md_5.bungee.api.ChatColor; | ||
import net.md_5.bungee.api.CommandSender; | ||
import net.md_5.bungee.api.ProxyServer; | ||
import net.md_5.bungee.api.connection.ProxiedPlayer; | ||
import net.md_5.bungee.api.plugin.Command; | ||
|
||
public class deleteplayer extends Command { | ||
public deleteplayer(){ | ||
super("deleteplayer", "adiauth.admin", "deleteuser"); | ||
} | ||
@Override | ||
public void execute(CommandSender sender, String[] args) { | ||
if(args.length != 1){ | ||
sender.sendMessage(ChatColor.YELLOW+"Please use /deleteplayer <username>"); | ||
return; | ||
} | ||
String username = args[0]; | ||
UserProfile profile = storage.getPlayerMemory(username); | ||
if(profile == null){ | ||
sender.sendMessage(ChatColor.YELLOW+"Player dosent exist"); | ||
} else { | ||
profile.password = null; | ||
profile.endSession(); | ||
ProxiedPlayer p = ProxyServer.getInstance().getPlayer(profile.uuid); | ||
if(p != null){ | ||
p.disconnect(ChatColor.RED+"Your Account has been deleted!"); | ||
} | ||
storage.deletePlayer(profile); | ||
sender.sendMessage("Successfully deleted "+profile.username); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters