-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4f24cdd
commit 48c147f
Showing
5 changed files
with
248 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Userinfo | ||
|
||
## 概要 | ||
プレイヤーの情報を閲覧し、1クリックで対処をします。 | ||
|
||
## 元ネタ | ||
このプラグインは[Hypixel Staff Mod Leak](https://www.youtube.com/watch?v=SDTRO0cx0Lc)をもとに作成されており、本家を忠実に再現しております。 | ||
|
||
## 注意 | ||
|
||
当プラグインはこのMODのサポートをしていますが、LynxModを使用しHypixelServerにアクセスした場合、 | ||
HypixelServerから永久的にアクセスを禁止される可能性がございます。 | ||
また、LynxModを使用してHypixelServerから永久的にアクセスを禁止された場合、当プラグイン作者は一切の責任を負いません。 | ||
|
||
## コマンド | ||
### コマンドドキュメントのみかた | ||
### /コマンド名 | ||
#### 概要 | ||
... | ||
#### エイリアス | ||
+ /エイリアス1 | ||
+ /エイリアス2 | ||
#### 使用方法:/コマンド名 \<必須パラメーター\> \[任意パラメーター\]... | ||
#### 権限:pybans.権限 | ||
--- | ||
### /userinfo | ||
#### 概要 | ||
プレイヤーの情報を閲覧します。 | ||
#### 使用法:/userinfo \[-f\] \<プレイヤー名\> | ||
#### 権限:userinfo.view | ||
--- | ||
## 権限 | ||
### userinfo.view | ||
#### 概要 | ||
/userinfoコマンドの権限です。 | ||
#### デフォルト:OP | ||
|
||
## 謝辞 | ||
+ [psac-serve/ban-manager](https://github.com/psac-serve/ban-manager) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 psac-serve | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,21 @@ | ||
package tokyo.peya.plugins.userinfo; | ||
|
||
import ml.peya.api.*; | ||
import ml.peya.plugins.*; | ||
|
||
import java.util.*; | ||
|
||
public class BanManager | ||
{ | ||
BanManagerAPI api; | ||
public BanManager() | ||
{ | ||
api = PeyangGreatBanManager.getAPI(); | ||
Userinfo.getThisOne().banEnabled = true; | ||
} | ||
|
||
public long getBans(UUID p) | ||
{ | ||
return api.getBans(p).size(); | ||
} | ||
} |
162 changes: 157 additions & 5 deletions
162
src/main/java/tokyo/peya/plugins/userinfo/Userinfo.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 |
---|---|---|
@@ -1,20 +1,172 @@ | ||
package tokyo.peya.plugins.userinfo; | ||
|
||
import net.md_5.bungee.api.chat.*; | ||
import org.bukkit.*; | ||
import org.bukkit.command.*; | ||
import org.bukkit.entity.*; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
public final class Userinfo extends JavaPlugin | ||
{ | ||
import java.text.*; | ||
import java.util.*; | ||
import java.util.stream.*; | ||
|
||
public class Userinfo extends JavaPlugin implements CommandExecutor | ||
{ | ||
BanManager banManager; | ||
public boolean banEnabled = false; | ||
public static Userinfo thisOne; | ||
@Override | ||
public void onEnable() | ||
{ | ||
// Plugin startup logic | ||
thisOne = this; | ||
|
||
Bukkit.getLogger().info("Userinfo has been activated!"); | ||
|
||
if (Bukkit.getPluginManager().isPluginEnabled("PeyangGreatBanManager")) | ||
banManager = new BanManager(); | ||
|
||
Bukkit.getPluginCommand("userinfo").setExecutor(thisOne); | ||
} | ||
|
||
public static Userinfo getThisOne() | ||
{ | ||
return thisOne; | ||
} | ||
|
||
private static BaseComponent[] action(String player) | ||
{ | ||
return new ComponentBuilder(ChatColor.GOLD + "Actions: ").append(ChatColor.AQUA + "[TPTO] ") | ||
.event(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tpto " + player)) | ||
.append(ChatColor.AQUA + "[BAN] ") | ||
.event(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/ban " + player + " ")) | ||
.append(ChatColor.AQUA + "[TEMPBAN] ") | ||
.event(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/tempban " + player + " ")) | ||
.append(ChatColor.AQUA + "[KICK] ") | ||
.event(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/psac kick " + player + " ")) | ||
.append(ChatColor.AQUA + "[MUTE] ") | ||
.event(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/mute " + player + " ")) | ||
.create(); | ||
} | ||
|
||
private static TextComponent t(String str) | ||
{ | ||
//String opts = ChatColor.RESET + ChatColor.WHITE.toString(); | ||
final String prefix = /*opts +*/ChatColor.GOLD.toString(); | ||
return new TextComponent(prefix + str + "\n"); | ||
} | ||
|
||
private static ArrayList<TextComponent> userInfo(OfflinePlayer offline, boolean lynx) | ||
{ | ||
Player player = offline.getPlayer(); | ||
ArrayList<TextComponent> p = new ArrayList<>(); | ||
|
||
|
||
final String data = ChatColor.WHITE.toString(); | ||
if (lynx) | ||
p.add(t("Most Recent Name: " + data + player.getName())); | ||
p.add(t("UUID: " + data + player.getUniqueId().toString())); | ||
|
||
String rank; | ||
if (player.hasPermission("psac.admin")) | ||
rank = ChatColor.RED + "ADMIN"; | ||
else if (player.hasPermission("psac.mod")) | ||
rank = ChatColor.DARK_GREEN + ChatColor.BOLD.toString() + "MOD"; | ||
else | ||
rank = ChatColor.GRAY + ChatColor.ITALIC.toString() + "MEMBER"; | ||
|
||
p.add(t("Rank: " + rank)); | ||
|
||
if (lynx) | ||
{ | ||
Stream.of("PackageRank: ", "OldPackageRank: ") | ||
.parallel() | ||
.map(s -> t(s + ChatColor.GRAY + ChatColor.ITALIC.toString() + "MEMBER")) | ||
.forEachOrdered(p::add); | ||
} | ||
|
||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:s z"); | ||
|
||
Stream.of( | ||
"Network Level: " + data + player.getTotalExperience(), | ||
"Network EXP: " + data + (int) player.getExp(), | ||
"Guild: " + ChatColor.GRAY + ChatColor.ITALIC.toString() + "NONE", | ||
"Current Server: " + data + player.getWorld().getName(), | ||
"First Login: " + data + formatter.format(new Date(offline.getFirstPlayed())), | ||
"Last Login: " + data + formatter.format(new Date(offline.getLastPlayed())), | ||
"Packages: ", | ||
"Boosters: " | ||
).parallel().map(Userinfo::t).forEachOrdered(p::add); | ||
|
||
long ban = thisOne.banEnabled ? thisOne.banManager.getBans(offline.getUniqueId()): 0; | ||
|
||
int kick = 0; | ||
int mute = 0; | ||
|
||
//TODO: カウンタ | ||
|
||
p.add(t(String.format( | ||
"Punishments: §a§lBans §r§f%d §6- §a§lMutes §r§f%d §r§6- §a§lKicks §r§f%d", | ||
ban, | ||
mute, | ||
kick | ||
))); | ||
|
||
return p; | ||
} | ||
|
||
@Override | ||
public void onDisable() | ||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) | ||
{ | ||
// Plugin shutdown logic | ||
if (!sender.hasPermission("userinfo.view")) | ||
{ | ||
sender.sendMessage(ChatColor.RED + "権限がありません!"); | ||
return true; | ||
} | ||
|
||
if (args.length < 1) | ||
{ | ||
sender.sendMessage(ChatColor.RED + "エラー:引数がおかしいです。"); | ||
return true; | ||
} | ||
|
||
|
||
final Player[] player = new Player[1]; | ||
boolean lynx = false; | ||
if (args[0].equals("-f")) | ||
{ | ||
player[0] = Bukkit.getPlayer(args[1]); | ||
lynx = true; | ||
} | ||
else | ||
player[0] = Bukkit.getPlayer(args[0]); | ||
|
||
if (player[0] == null) | ||
{ | ||
Arrays.stream(Bukkit.getOfflinePlayers()) | ||
.parallel() | ||
.filter(op -> !op.getName().equals(args[0]) || | ||
!op.getName().equals(args[1])) | ||
.forEachOrdered(op -> player[0] = op.getPlayer()); | ||
|
||
if (player[0] == null) | ||
{ | ||
sender.sendMessage(ChatColor.RED + "エラー:プレイヤーが見つかりませんでした。"); | ||
|
||
return true; | ||
} | ||
} | ||
|
||
final String opts = ChatColor.RESET + ChatColor.WHITE.toString(); | ||
final String prefix = opts + ChatColor.GOLD; | ||
ComponentBuilder builder = new ComponentBuilder(ChatColor.GOLD + | ||
"--- Info about " + | ||
player[0].getName() + | ||
prefix + | ||
" ---\n"); | ||
userInfo(player[0], lynx).parallelStream() | ||
.forEachOrdered(builder::append); | ||
sender.spigot().sendMessage(builder.append(action(player[0].getName())).create()); | ||
|
||
return true; | ||
} | ||
} |