Skip to content

Commit

Permalink
Add command to change fronter
Browse files Browse the repository at this point in the history
  • Loading branch information
Kurumi78 committed Aug 21, 2024
1 parent b025122 commit e1dc338
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main/java/com/gmail/kurumitk78/systemswap/SystemSwap.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,10 @@ public static UUID createSystem(UUID playerUUID){
systemMapSystemUUID.put(systemUUID, systemMapPlayerUUID.get(playerUUID));
return systemUUID;
}
public static void deleteSystemPlayerUUID(UUID playerUUID){
systemMapPlayerUUID.remove(playerUUID);
}
public static void deleteSystemSystemUUID(UUID systemUUID){
systemMapSystemUUID.remove(systemUUID);
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package com.gmail.kurumitk78.systemswap.commands;

import com.gmail.kurumitk78.systemswap.Alter;
import com.gmail.kurumitk78.systemswap.System;
import com.gmail.kurumitk78.systemswap.SystemSwap;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;

import java.util.ArrayList;
import java.util.UUID;
import java.util.logging.Level;

Expand All @@ -18,6 +22,9 @@ public boolean onCommand(CommandSender commandSender, Command command, String s,
case "create":
createAlterCommand((Player) commandSender);
break;
case "delete":
deleteAlterCommand((Player) commandSender);
break;
}

}
Expand All @@ -42,7 +49,27 @@ private void createAlterCommand(Player player){
}

private void deleteAlterCommand(Player player){
if(SystemSwap.getSystemFromPlayerUUID(player.getUniqueId()) != null){
UUID systemUUID = SystemSwap.getSystemFromPlayerUUID(player.getUniqueId()).getSystemUUID();
SystemSwap.deleteSystemSystemUUID(systemUUID);
SystemSwap.deleteSystemPlayerUUID(player.getUniqueId());

}

}
private void setFronterCommand(Player player, String alterName){
System playerSystem = SystemSwap.getSystemFromPlayerUUID(player.getUniqueId());
ArrayList<Alter> alters = new ArrayList<>();
alters.addAll(playerSystem.getAlterList().values());
for(int iterations = 0; iterations < alters.size(); iterations++) {
if(alters.get(iterations).getName().toLowerCase() == alterName){
playerSystem.setFronter(alters.get(iterations));
break;
}
else if(iterations == alters.size()){
player.sendMessage("Alter with name " + alterName + " not found.");
}
}
}

}

0 comments on commit e1dc338

Please sign in to comment.