9
0
mirror of https://github.com/Xiao-MoMi/Custom-Nameplates.git synced 2025-12-29 19:59:09 +00:00

velocity module

This commit is contained in:
XiaoMoMi
2024-01-21 18:03:00 +08:00
parent d6ac11e8b3
commit b2f329332d
44 changed files with 352 additions and 81 deletions

42
common/.gitignore vendored Normal file
View File

@@ -0,0 +1,42 @@
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

3
common/build.gradle.kts Normal file
View File

@@ -0,0 +1,3 @@
dependencies {
compileOnly("org.jetbrains:annotations:24.1.0")
}

View File

@@ -0,0 +1,46 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customnameplates.common;
public record Key(String namespace, String value) {
public static Key of(String namespace, String value) {
return new Key(namespace, value);
}
@Override
public int hashCode() {
int result = this.namespace.hashCode();
result = (31 * result) + this.value.hashCode();
return result;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (!(obj instanceof Key key)) return false;
return this.namespace.equals(key.namespace()) && this.value.equals(key.value());
}
@Override
public String toString() {
return namespace + ":" + value;
}
}

View File

@@ -0,0 +1,25 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customnameplates.common;
public record Pair<L, R>(L left, R right) {
public static <L, R> Pair<L, R> of(final L left, final R right) {
return new Pair<>(left, right);
}
}

View File

@@ -0,0 +1,57 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customnameplates.common;
import java.util.Objects;
public record SimpleLocation(String worldName, int x, int y, int z) {
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final SimpleLocation other = (SimpleLocation) obj;
if (!Objects.equals(worldName, other.worldName())) {
return false;
}
if (Double.doubleToLongBits(this.x) != Double.doubleToLongBits(other.x)) {
return false;
}
if (Double.doubleToLongBits(this.y) != Double.doubleToLongBits(other.y)) {
return false;
}
if (Double.doubleToLongBits(this.z) != Double.doubleToLongBits(other.z)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int hash = 3;
hash = 19 * hash + (worldName != null ? worldName.hashCode() : 0);
hash = 19 * hash + (int) (Double.doubleToLongBits(this.x) ^ (Double.doubleToLongBits(this.x) >>> 32));
hash = 19 * hash + (int) (Double.doubleToLongBits(this.y) ^ (Double.doubleToLongBits(this.y) >>> 32));
hash = 19 * hash + (int) (Double.doubleToLongBits(this.z) ^ (Double.doubleToLongBits(this.z) >>> 32));
return hash;
}
}

View File

@@ -0,0 +1,68 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customnameplates.common;
public class Tuple<L, M, R> {
private L left;
private M mid;
private R right;
public Tuple(L left, M mid, R right) {
this.left = left;
this.mid = mid;
this.right = right;
}
public static <L, M, R> Tuple<L, M, R> of(final L left, final M mid, final R right) {
return new Tuple<>(left, mid, right);
}
public L getLeft() {
return left;
}
public void setLeft(L left) {
this.left = left;
}
public M getMid() {
return mid;
}
public void setMid(M mid) {
this.mid = mid;
}
public R getRight() {
return right;
}
public void setRight(R right) {
this.right = right;
}
@Override
public String toString() {
return "Tuple{" +
"left=" + left +
", mid=" + mid +
", right=" + right +
'}';
}
}

View File

@@ -0,0 +1,8 @@
package net.momirealms.customnameplates.common.message;
public class MessageType {
public static final String CREATE = "0";
public static final String REMOVE = "1";
public static final String UPDATE = "2";
}

View File

@@ -0,0 +1,31 @@
package net.momirealms.customnameplates.common.team;
import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
public enum TeamCollisionRule {
ALWAYS("always"),
NEVER("never"),
PUSH_OTHER_TEAMS("pushOtherTeams"),
PUSH_OWN_TEAM("pushOwnTeam");
private final String id;
TeamCollisionRule(@NotNull String id) {
this.id = id;
}
public String getId() {
return id;
}
@NotNull
public static TeamCollisionRule byId(String id) {
return Arrays.stream(values())
.filter(mode -> mode.id.equals(id))
.findFirst()
.orElse(ALWAYS);
}
}

View File

@@ -0,0 +1,29 @@
package net.momirealms.customnameplates.common.team;
import java.util.Locale;
public enum TeamColor {
NONE,
BLACK,
DARK_BLUE,
DARK_GREEN,
DARK_AQUA,
DARK_RED,
DARK_PURPLE,
GOLD,
GRAY,
DARK_GRAY,
BLUE,
GREEN,
AQUA,
RED,
LIGHT_PURPLE,
YELLOW,
WHITE,
CUSTOM;
public TeamColor getById(String id) throws IllegalArgumentException {
return valueOf(id.toUpperCase(Locale.ENGLISH));
}
}

View File

@@ -0,0 +1,31 @@
package net.momirealms.customnameplates.common.team;
import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
public enum TeamTagVisibility {
ALWAYS("always"),
HIDE_FOR_OTHER_TEAMS("hideForOtherTeams"),
HIDE_FOR_OWN_TEAM("hideForOwnTeam"),
NEVER("never");
private final String id;
TeamTagVisibility(@NotNull String id) {
this.id = id;
}
public String getId() {
return id;
}
@NotNull
public static TeamTagVisibility byId(String id) {
return Arrays.stream(values())
.filter(mode -> mode.id.equals(id))
.findFirst()
.orElse(ALWAYS);
}
}