Skip to content

Commit

Permalink
Release 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
PeyaPeyaPeyang committed Jan 9, 2021
1 parent 4f24cdd commit 48c147f
Showing 5 changed files with 248 additions and 22 deletions.
39 changes: 39 additions & 0 deletions README.md
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)
27 changes: 10 additions & 17 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@

<groupId>tokyo.peya.plugins</groupId>
<artifactId>Userinfo</artifactId>
<version>1.0-SNAPSHOT</version>
<version>1.0</version>
<packaging>jar</packaging>

<name>Userinfo</name>
@@ -29,22 +29,6 @@
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
@@ -63,6 +47,10 @@
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>

<dependencies>
@@ -72,5 +60,10 @@
<version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.psac-serve</groupId>
<artifactId>ban-manager</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</project>
21 changes: 21 additions & 0 deletions src/LICENSE
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.
21 changes: 21 additions & 0 deletions src/main/java/tokyo/peya/plugins/userinfo/BanManager.java
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 src/main/java/tokyo/peya/plugins/userinfo/Userinfo.java
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;
}
}

0 comments on commit 48c147f

Please sign in to comment.