added colorkey and fixed scaling command
This commit is contained in:
parent
a61363c8e1
commit
dd5cfe1405
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -3,7 +3,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = 'com.newt-tech'
|
group = 'com.newt-tech'
|
||||||
version = '1.1-BETA'
|
version = '1.2-BETA'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
Binary file not shown.
Binary file not shown.
BIN
build/libs/CoswayUtil-1.2-BETA.jar
Normal file
BIN
build/libs/CoswayUtil-1.2-BETA.jar
Normal file
Binary file not shown.
@ -1,8 +1,11 @@
|
|||||||
name: CoswayUtil
|
name: CoswayUtil
|
||||||
version: '1.1-BETA'
|
version: '1.2-BETA'
|
||||||
main: CoswayUtil.CoswayUtil
|
main: CoswayUtil.CoswayUtil
|
||||||
authors: ["Newt_00"]
|
|
||||||
description: "utility plugin for Cosway servers, a yescraft network server"
|
description: "utility plugin for Cosway servers, a yescraft network server"
|
||||||
api-version: '1.21'
|
api-version: '1.21'
|
||||||
author: "Newt_00"
|
author: "Newt_00"
|
||||||
website: "ycs.Newt-Tech.com"
|
website: "ycs.Newt-Tech.com"
|
||||||
|
commands:
|
||||||
|
scale:
|
||||||
|
permission: cosway.admin
|
||||||
|
usage: "/scale <float>"
|
Binary file not shown.
Binary file not shown.
@ -1,5 +1,6 @@
|
|||||||
package CoswayUtil;
|
package CoswayUtil;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
@ -7,19 +8,20 @@ import org.bukkit.entity.Entity;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.RayTraceResult;
|
import org.bukkit.util.RayTraceResult;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public final class CoswayUtil extends JavaPlugin {
|
public final class CoswayUtil extends JavaPlugin {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
serverMessage("aw sheit here we go again....");
|
serverMessage(ColorKey("&aaw sheit here we go again...."));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
serverMessage("im dead, im alive but im dead....");
|
serverMessage(ColorKey("&cim dead, im alive but im dead...."));
|
||||||
}
|
}
|
||||||
public boolean onCommand(@NotNull CommandSender sender, Command cmd, @NotNull String label, String[] args) {
|
public boolean onCommand(@NotNull CommandSender sender, Command cmd, @NotNull String label, String[] args) {
|
||||||
if (cmd.getName().equalsIgnoreCase("scale") && sender instanceof Player) {
|
if (cmd.getName().equalsIgnoreCase("scale") && sender instanceof Player) {
|
||||||
@ -27,7 +29,7 @@ public final class CoswayUtil extends JavaPlugin {
|
|||||||
if (args.length < 1) {
|
if (args.length < 1) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
setScale(player, Float.parseFloat(args[1]));
|
setScale(player, Float.parseFloat(args[0]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -40,23 +42,37 @@ public final class CoswayUtil extends JavaPlugin {
|
|||||||
RayTraceResult result = player.getWorld().rayTraceEntities(
|
RayTraceResult result = player.getWorld().rayTraceEntities(
|
||||||
player.getEyeLocation(),
|
player.getEyeLocation(),
|
||||||
player.getEyeLocation().getDirection(),
|
player.getEyeLocation().getDirection(),
|
||||||
10, // Max distance to check
|
10,
|
||||||
entity -> entity != player // Ignore the player themselves
|
entity -> entity instanceof Player == false // Ignore the player
|
||||||
);
|
);
|
||||||
|
|
||||||
if (result != null && result.getHitEntity() != null) {
|
if (result != null && result.getHitEntity() != null) {
|
||||||
Entity entity = result.getHitEntity();
|
Entity entity = result.getHitEntity();
|
||||||
|
String entityUUID = entity.getUniqueId().toString();
|
||||||
|
|
||||||
try {
|
String command = "attribute " + entityUUID + " minecraft:scale base set " + value;
|
||||||
entity.getClass().getMethod("setScale", float.class).invoke(entity, value);
|
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
|
||||||
} catch (Exception e) {
|
|
||||||
player.sendMessage("§cThis entity does not support scaling!");
|
player.sendMessage("§aSet scale of " + entity.getName() + " to " + value);
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage("§cNo entity found in sight!");
|
player.sendMessage("§cNot Looking at any entity!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public String ColorKey(String t) {
|
||||||
|
char searchChar = '&'; // Character to search for
|
||||||
|
char replacementChar = '§'; // Character to replace with
|
||||||
|
StringBuilder sb = new StringBuilder(t);
|
||||||
|
// Search for the character in the StringBuilder
|
||||||
|
int index = sb.indexOf(String.valueOf(searchChar));
|
||||||
|
|
||||||
|
// Replace the character if found
|
||||||
|
for (int j = 0; j < sb.length(); j++) {
|
||||||
|
if (sb.charAt(j) == searchChar) {
|
||||||
|
sb.setCharAt(j, replacementChar);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
public void serverMessage(String msg) {
|
public void serverMessage(String msg) {
|
||||||
getServer().broadcastMessage(prefix()+msg);
|
getServer().broadcastMessage(prefix()+msg);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
name: CoswayUtil
|
name: CoswayUtil
|
||||||
version: '1.1-BETA'
|
version: '1.2-BETA'
|
||||||
main: CoswayUtil.CoswayUtil
|
main: CoswayUtil.CoswayUtil
|
||||||
authors: ["Newt_00"]
|
|
||||||
description: "utility plugin for Cosway servers, a yescraft network server"
|
description: "utility plugin for Cosway servers, a yescraft network server"
|
||||||
api-version: '1.21'
|
api-version: '1.21'
|
||||||
author: "Newt_00"
|
author: "Newt_00"
|
||||||
@ -9,4 +8,4 @@ website: "ycs.Newt-Tech.com"
|
|||||||
commands:
|
commands:
|
||||||
scale:
|
scale:
|
||||||
permission: cosway.admin
|
permission: cosway.admin
|
||||||
usage: /scale <float>
|
usage: "/scale <float>"
|
Loading…
Reference in New Issue
Block a user