Skip to content

Commit

Permalink
2.2.0.4
Browse files Browse the repository at this point in the history
-Renames IdUtil so that it's clear that it's only for local presences

Took 2 minutes
  • Loading branch information
Jake-Moore committed Dec 10, 2023
1 parent b8bb555 commit 9f001ac
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 41 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.kamikazejam</groupId>
<artifactId>kamicommon</artifactId>
<version>2.2.0.3</version>
<version>2.2.0.4</version>
<packaging>jar</packaging>

<name>KamiCommon</name>
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/kamikazejam/kamicommon/KamiCommon.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import com.kamikazejam.kamicommon.util.collections.KamiMap;
import com.kamikazejam.kamicommon.util.collections.KamiSet;
import com.kamikazejam.kamicommon.util.collections.KamiTreeSet;
import com.kamikazejam.kamicommon.util.id.IdUtil;
import com.kamikazejam.kamicommon.util.id.IdUtilLocal;
import com.kamikazejam.kamicommon.util.mson.Mson;
import com.kamikazejam.kamicommon.util.mson.MsonEvent;
import com.kamikazejam.kamicommon.yaml.standalone.YamlUtil;
Expand Down Expand Up @@ -48,7 +48,7 @@ public void onEnableInner(){
YamlUtil.getYaml();

// Setup IdUtil
IdUtil.setup();
IdUtilLocal.setup();

// Setup RegistryType (Types for Commands)
RegistryType.registerAll();
Expand All @@ -65,7 +65,7 @@ public void onDisableInner() {
HandlerList.unregisterAll((Plugin) plugin);

// Save IdUtil
IdUtil.saveCachefileDatas();
IdUtilLocal.saveCachefileDatas();

Bukkit.getLogger().info("KamiCommon disabled");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.kamikazejam.kamicommon.util.exception.KamiCommonException;
import com.kamikazejam.kamicommon.command.type.TypeAbstract;
import com.kamikazejam.kamicommon.util.id.IdUtil;
import com.kamikazejam.kamicommon.util.id.IdUtilLocal;
import com.kamikazejam.kamicommon.util.id.SenderPresence;
import com.kamikazejam.kamicommon.util.id.SenderType;
import org.bukkit.OfflinePlayer;
Expand All @@ -25,12 +25,12 @@ public static TypeOfflinePlayer get() {

@Override
public OfflinePlayer read(String str, CommandSender sender) throws KamiCommonException {
return IdUtil.getOfflinePlayer(str);
return IdUtilLocal.getOfflinePlayer(str);
}

@Override
public Collection<String> getTabList(CommandSender commandSender, String s) {
return IdUtil.getNames(SenderPresence.LOCAL, SenderType.PLAYER).stream()
return IdUtilLocal.getNames(SenderPresence.LOCAL, SenderType.PLAYER).stream()
.filter(key -> key.toLowerCase().startsWith(s.toLowerCase())).limit(20)
.collect(Collectors.toList());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.kamikazejam.kamicommon.util.exception.KamiCommonException;
import com.kamikazejam.kamicommon.command.type.TypeAbstract;
import com.kamikazejam.kamicommon.util.id.IdUtil;
import com.kamikazejam.kamicommon.util.id.IdUtilLocal;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

Expand All @@ -23,7 +23,7 @@ public static TypeSender get() {

@Override
public CommandSender read(String str, CommandSender sender) throws KamiCommonException {
return IdUtil.getSender(str);
return IdUtilLocal.getSender(str);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.kamikazejam.kamicommon.util.engine;

import com.kamikazejam.kamicommon.util.KUtil;
import com.kamikazejam.kamicommon.util.id.IdUtil;
import com.kamikazejam.kamicommon.util.id.IdUtilLocal;
import com.kamikazejam.kamicommon.util.mson.MsonMessenger;
import com.kamikazejam.kamicommon.util.teleport.ScheduledTeleport;
import org.bukkit.entity.Entity;
Expand Down Expand Up @@ -91,7 +91,7 @@ public void cancelTeleport(Player player) {
if (KUtil.isntPlayer(player)) return;

// If there there is a ScheduledTeleport ...
ScheduledTeleport scheduledTeleport = teleporteeIdToScheduledTeleport.get(IdUtil.getId(player));
ScheduledTeleport scheduledTeleport = teleporteeIdToScheduledTeleport.get(IdUtilLocal.getId(player));
if (scheduledTeleport == null) return;

// ... unschedule it ...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,16 @@
* Non standard CommandSenders must be manually registered using the register method.
*/
@SuppressWarnings({"SpellCheckingInspection", "unused", "ResultOfMethodCallIgnored"})
public class IdUtil implements Listener, Runnable {
public class IdUtilLocal implements Listener, Runnable {
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
// This class mostly contains static content.
// A few things needs an instantiated class though.
// Such as the event listeners.

private static final IdUtil i = new IdUtil();

public static IdUtil get() {
return i;
}
private static final IdUtilLocal i = new IdUtilLocal();
public static IdUtilLocal get() { return i; }

// -------------------------------------------- //
// CONSTANTS
Expand Down Expand Up @@ -402,7 +399,7 @@ public void playerLoginLowest(@NotNull PlayerLoginEvent event) {
// Declaring Existence? Sure, whatever you were before!
// It can definitely not be local at this point.
// But online or offline is fine.
boolean online = IdUtil.isOnline(player);
boolean online = IdUtilLocal.isOnline(player);

update(id, name, SenderPresence.fromOnline(online));
}
Expand Down Expand Up @@ -752,7 +749,7 @@ public static boolean isOnline(Object senderObject) {
if (CONSOLE_ID.equals(id)) return true;

// ... return by (case insensitive) set contains.
return IdUtil.getIds(SenderPresence.ONLINE, SenderType.ANY).contains(id);
return IdUtilLocal.getIds(SenderPresence.ONLINE, SenderType.ANY).contains(id);
}

@Contract("null -> null")
Expand All @@ -773,7 +770,7 @@ public static boolean isPlayerId(String string) {

@Contract("null -> false")
public static boolean isPlayer(Object senderObject) {
String id = IdUtil.getId(senderObject);
String id = IdUtilLocal.getId(senderObject);
if (id == null) return false;
return isPlayerId(id);
}
Expand All @@ -785,7 +782,7 @@ public static boolean isConsoleId(String string) {

@Contract("null -> false")
public static boolean isConsole(Object senderObject) {
String id = IdUtil.getId(senderObject);
String id = IdUtilLocal.getId(senderObject);
if (id == null) return false;
return isConsoleId(id);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public boolean removeValueCompletely(String value) {
}

public static boolean isPlayerValue(String value) {
return IdUtil.isPlayerId(value);
return IdUtilLocal.isPlayerId(value);
//return MUtil.isValidPlayerName(value) || MUtil.isUuid(value);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.kamikazejam.kamicommon.util.mixin;

import com.kamikazejam.kamicommon.util.id.IdUtil;
import com.kamikazejam.kamicommon.util.id.IdUtilLocal;
import com.kamikazejam.kamicommon.util.mson.Mson;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
Expand Down Expand Up @@ -34,21 +34,21 @@ public Mson getDisplayNameMson(Object senderObject, Object watcherObject) {
}

public String getDisplayName(Object senderObject, Object watcherObject) {
String senderId = IdUtil.getId(senderObject);
String senderId = IdUtilLocal.getId(senderObject);
if (senderId == null) return null;

// Ret
String ret = null;

// Bukkit
Player player = IdUtil.getPlayer(senderObject);
Player player = IdUtilLocal.getPlayer(senderObject);
if (player != null) {
ret = player.getDisplayName();
}

// Fixed Name
if (ret == null) {
ret = IdUtil.getName(senderObject);
ret = IdUtilLocal.getName(senderObject);
}

// Id Fallback
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.kamikazejam.kamicommon.util.mixin;

import com.kamikazejam.kamicommon.util.KUtil;
import com.kamikazejam.kamicommon.util.id.IdUtil;
import com.kamikazejam.kamicommon.util.id.IdUtilLocal;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.Contract;
Expand All @@ -28,7 +28,7 @@ public static MixinPlayed get() {
// -------------------------------------------- //

public boolean isOnline(Object senderObject) {
return IdUtil.isOnline(senderObject);
return IdUtilLocal.isOnline(senderObject);
}

public boolean isOffline(Object senderObject) {
Expand All @@ -38,7 +38,7 @@ public boolean isOffline(Object senderObject) {
public Long getFirstPlayed(Object senderObject) {
if (KUtil.isNpc(senderObject)) return null;

UUID uuid = IdUtil.getUuid(senderObject);
UUID uuid = IdUtilLocal.getUuid(senderObject);
if (uuid == null) return null;
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(uuid);

Expand All @@ -55,7 +55,7 @@ public Long getLastPlayed(Object senderObject) {

if (KUtil.isNpc(senderObject)) return null;

UUID uuid = IdUtil.getUuid(senderObject);
UUID uuid = IdUtilLocal.getUuid(senderObject);
if (uuid == null) return null;
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(uuid);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.kamikazejam.kamicommon.util.mixin;

import com.kamikazejam.kamicommon.util.id.IdUtil;
import com.kamikazejam.kamicommon.util.id.IdUtilLocal;
import com.kamikazejam.kamicommon.util.teleport.ps.PS;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.Contract;
Expand All @@ -25,7 +25,7 @@ public static MixinSenderPs get() {
// -------------------------------------------- //

public PS getSenderPs(Object senderObject) {
Player player = IdUtil.getPlayer(senderObject);
Player player = IdUtilLocal.getPlayer(senderObject);
if (player == null) return null;
return PS.valueOf(player.getLocation());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.kamikazejam.kamicommon.util.Txt;
import com.kamikazejam.kamicommon.util.engine.EngineTeleportMixinCause;
import com.kamikazejam.kamicommon.util.exception.KamiCommonException;
import com.kamikazejam.kamicommon.util.id.IdUtil;
import com.kamikazejam.kamicommon.util.id.IdUtilLocal;
import com.kamikazejam.kamicommon.util.mson.MsonMessenger;
import com.kamikazejam.kamicommon.util.teleport.Destination;
import com.kamikazejam.kamicommon.util.teleport.ScheduledTeleport;
Expand Down Expand Up @@ -95,9 +95,9 @@ public static void teleportPlayer(@NotNull Player player, @NotNull PS ps) throws
// -------------------------------------------- //

public void teleport(Object teleporteeObject, Destination destination, int delaySeconds) throws KamiCommonException {
String teleporteeId = IdUtil.getId(teleporteeObject);
if (!IdUtil.isPlayerId(teleporteeId))
throw new KamiCommonException().addMsg(Txt.parse("<white>%s <b>is not a player.", MixinDisplayName.get().getDisplayName(teleporteeId, IdUtil.getConsole())));
String teleporteeId = IdUtilLocal.getId(teleporteeObject);
if (!IdUtilLocal.isPlayerId(teleporteeId))
throw new KamiCommonException().addMsg(Txt.parse("<white>%s <b>is not a player.", MixinDisplayName.get().getDisplayName(teleporteeId, IdUtilLocal.getConsole())));

PS ps;
try {
Expand Down Expand Up @@ -130,7 +130,7 @@ public void teleport(Object teleporteeObject, Destination destination, int delay
MsonMessenger.get().msgOne(teleporteeId, "<i>Teleporting to <h>" + desc + "<i>.");
}

Player teleportee = IdUtil.getPlayer(teleporteeId);
Player teleportee = IdUtilLocal.getPlayer(teleporteeId);
if (teleportee != null) {
teleportPlayer(teleportee, ps);
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.kamikazejam.kamicommon.util.teleport;

import com.kamikazejam.kamicommon.util.Txt;
import com.kamikazejam.kamicommon.util.id.IdUtil;
import com.kamikazejam.kamicommon.util.id.IdUtilLocal;
import com.kamikazejam.kamicommon.util.mixin.MixinDisplayName;
import com.kamikazejam.kamicommon.util.mixin.MixinPlayed;
import com.kamikazejam.kamicommon.util.mixin.MixinSenderPs;
Expand All @@ -24,15 +24,15 @@ public void setPlayerId(String playerId) {
}

public void setPlayer(Object playerObject) {
this.playerId = IdUtil.getId(playerObject);
this.playerId = IdUtilLocal.getId(playerObject);
}

public CommandSender getSender() {
return IdUtil.getSender(this.playerId);
return IdUtilLocal.getSender(this.playerId);
}

public Player getPlayer() {
return IdUtil.getPlayer(this.playerId);
return IdUtilLocal.getPlayer(this.playerId);
}

// -------------------------------------------- //
Expand Down

0 comments on commit 9f001ac

Please sign in to comment.