Skip to content

Commit

Permalink
1.0-Revamp
Browse files Browse the repository at this point in the history
  • Loading branch information
AzureHanChen committed Aug 29, 2021
0 parents commit af320bb
Show file tree
Hide file tree
Showing 36 changed files with 2,310 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# ��Ŀ�ų�·��
/out/
/target/
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/artifacts/LobbyLevel.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/libraries/PlaceholderAPI_2_10_10.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions .idea/libraries/spigot_1_8_8.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Manifest-Version: 1.0

24 changes: 24 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>groupId</groupId>
<artifactId>decompiled-LobbyLevel</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>


</project>
183 changes: 183 additions & 0 deletions src/main/java/me/yuzegod/lobbylevel/Account.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
package me.yuzegod.lobbylevel;

import org.bukkit.entity.*;
import org.bukkit.scheduler.*;
import me.yuzegod.lobbylevel.Database.*;
import java.util.*;
import java.text.*;
import org.bukkit.*;
import org.bukkit.event.*;
import me.yuzegod.lobbylevel.Event.*;
import org.bukkit.plugin.*;

public class Account
{
private static HashMap<Player, Account> accounts;
private static boolean initialized;
private static BukkitRunnable refreshTask;
private DataBase database;
private Player player;
private int level;
private int exp;

static {
Account.accounts = new HashMap<Player, Account>();
Account.initialized = false;
}

private Account(final Player player) {
this.player = player;
this.database = LobbyLevel.getInstance().getDataBase();
if (!this.database.isValueExists(LobbyLevel.TABLENAME, LobbyLevel.KV, new KeyValue("name", player.getName()))) {
this.database.dbInsert(LobbyLevel.TABLENAME, new KeyValue("name", player.getName()).add("exp", 0).add("level", 1).add("rewards", ""));
}
this.refresh();
}

public void refresh() {
for (final KeyValue kv : this.database.dbSelect(LobbyLevel.TABLENAME, LobbyLevel.KV, new KeyValue("name", this.player.getName()))) {
this.exp = Integer.parseInt(kv.getString("exp"));
this.level = Integer.parseInt(kv.getString("level"));
}
this.setExp(this.exp);
this.setLevel(this.level);
}

public Player getPlayer() {
return this.player;
}

public void reset() {
this.setLevel(1);
this.setExp(0);
}

public int getLevel() {
return this.level;
}

public int getExp() {
return this.exp;
}

public int getUpExp() {
return this.getTotalExp(this.level) - this.exp;
}

public int getTotalExp(final int Level) {
return 1000 + Level * 200;
}

public float getExpFloat() {
float f = this.exp / (float)this.getTotalExp(this.level);
if (f > 1.0f) {
f = 0.99f;
}
else if (f < 0.0f) {
f = 0.0f;
}
return f;
}

public String getLevelJinDu() {
final double i = new Double(this.exp / (double)this.getTotalExp(this.level)) * 10.0;
final StringBuilder stb1 = new StringBuilder("¡ìb");
for (int a = 0; a < (int)i; ++a) {
stb1.append("\u25a0");
}
final StringBuilder stb2 = new StringBuilder("¡ì7");
for (int b = 0; b < 10 - (int)i; ++b) {
stb2.append("\u25a0");
}
return String.valueOf(stb1.toString()) + stb2.toString();
}

public String getLevelBaiFenBi() {
final double i = new Double(this.exp / (double)this.getTotalExp(this.level));
final NumberFormat nt = NumberFormat.getPercentInstance();
nt.setMinimumFractionDigits(1);
return nt.format(i);
}

public void setLevel(final int i) {
if (i <= 0) {
return;
}
this.level = i;
this.database.dbUpdate(LobbyLevel.TABLENAME, new KeyValue("level", i), new KeyValue("name", this.player.getName()));
if (LobbyLevel.getInstance().getConfig().getBoolean("show-Action", false)) {
this.player.setLevel(this.level);
}
}

private void setExp(final int i) {
if (i < 0) {
return;
}
this.exp = i;
this.database.dbUpdate(LobbyLevel.TABLENAME, new KeyValue("exp", i), new KeyValue("name", this.player.getName()));
if (LobbyLevel.getInstance().getConfig().getBoolean("show-Action", false)) {
this.player.setExp(this.getExpFloat());
}
}

public void giveExp(final int key) {
if (key <= 0 || key >= 1400) {
return;
}
final ExpChangeEvent expchange = new ExpChangeEvent(this.player, key);
Bukkit.getPluginManager().callEvent((Event)expchange);
if (expchange.isCancelled()) {
return;
}
int amount = expchange.getAmount();
if (amount >= 1400) {
amount = 1399;
}
if (amount < 1400) {
if (amount >= this.getUpExp()) {
final LevelUpEvent event = new LevelUpEvent(this.player, this.level, this.level + 1);
Bukkit.getPluginManager().callEvent((Event)event);
this.setExp(amount - this.getUpExp());
this.setLevel(this.level + 1);
}
else {
this.setExp(this.exp + amount);
}
}
if (LobbyLevel.getInstance().getConfig().getBoolean("show-Action", false)) {
this.player.setExp(this.getExpFloat());
}
}

public static boolean init() {
if (Account.initialized) {
return false;
}
(Account.refreshTask = new BukkitRunnable() {
public void run() {
for (final Account set : Account.accounts.values()) {
set.refresh();
}
}
}).runTaskTimer((Plugin)LobbyLevel.getInstance(), 1200L, 1200L);
return true;
}

public static Account get(final Player player) {
Account set = null;
if (Account.accounts.containsKey(player)) {
return Account.accounts.get(player);
}
set = new Account(player);
Account.accounts.put(player, set);
return set;
}

public static boolean remove(final Player player) {
if (Account.accounts.containsKey(player)) {
Account.accounts.remove(player);
}
return false;
}
}
19 changes: 19 additions & 0 deletions src/main/java/me/yuzegod/lobbylevel/Command/Cmd.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package me.yuzegod.lobbylevel.Command;

import java.lang.annotation.*;

@Target({ ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
public @interface Cmd {
String value() default "";

int minArgs() default 0;

String description() default "";

String permission() default "LobbyLevel.default";

boolean onlyPlayer() default false;

boolean onlyConsole() default false;
}
Loading

0 comments on commit af320bb

Please sign in to comment.