Skip to content

Commit

Permalink
Better messages and new version
Browse files Browse the repository at this point in the history
  • Loading branch information
CoPokBl committed Mar 26, 2024
1 parent bf874a4 commit c825f3c
Show file tree
Hide file tree
Showing 24 changed files with 61 additions and 59 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>net.serble.EsTools</groupId>
<artifactId>EsTools</artifactId>
<version>3.3</version>
<version>4.0</version>
<packaging>jar</packaging>

<name>EsTools</name>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/serble/estools/CMD.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ public static String[] removeArgs(String[] args, int amount) {
return outp;
}

public static String argsToString(String[] args, int amount) {
public static String argsToString(String[] args, int skipAmount) {
StringBuilder outp = new StringBuilder();

for (int i = amount; i < args.length; i++) {
for (int i = skipAmount; i < args.length; i++) {
outp.append(args[i]);
}

Expand Down
1 change: 0 additions & 1 deletion src/main/java/net/serble/estools/Commands/CChest.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
p.openInventory(inv);

cchests.put(puid, inv);

return true;
}

Expand Down
6 changes: 6 additions & 0 deletions src/main/java/net/serble/estools/Commands/Feed.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
p.setFoodLevel(20);
p.setSaturation(20);
}

if (args.length == 0) {
s(sender, "&aFed!");
} else {
s(sender, "&aFed &6%s&a!", args[0]);
}
return true;
}

Expand Down
20 changes: 9 additions & 11 deletions src/main/java/net/serble/estools/Commands/Fix.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,33 +78,31 @@ public boolean onCommand(CommandSender sender, Command command, String label, St

p.getInventory().setContents(contents);
} else {
ItemStack ir = Repair(is);
//
// if (ir != null) {
// is = ir.clone();
// }
}
Repair(is);
}

s(sender, "&aRepaired &6%s's &aitem(s)!", getEntityName(p));
return true;
}

private ItemStack Repair(ItemStack is) {
if (is == null)
return null;
private void Repair(ItemStack is) {
if (is == null) {
return;
}

if (Main.version > 12) {
ItemMeta im = is.getItemMeta();

if (im == null) return null;
if (im == null) return;

((Damageable) im).setDamage(0);

is.setItemMeta(im);
} else {
//noinspection deprecation
is.setDurability((short) 0);
}

return is;
}

@Override
Expand Down
11 changes: 3 additions & 8 deletions src/main/java/net/serble/estools/Commands/Fly.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.bukkit.entity.Player;

import java.util.ArrayList;
import java.util.Objects;

public class Fly extends MultiPlayerCommand {

Expand All @@ -26,16 +27,10 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
return false;
}

Player s = null;

if (sender instanceof Player) {
s = (Player)sender;
}

for (Player p : ps) {
for (Player p : ps) {
boolean isFly = p.getAllowFlight();

if (args.length != 0 && args[0] != "*") {
if (args.length != 0 && !Objects.equals(args[0], "*")) {
if (isFly)
s(sender, "&aFly Disabled for &6%s", p.getName());
else
Expand Down
13 changes: 2 additions & 11 deletions src/main/java/net/serble/estools/Commands/GetInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
}
}

// Living entity
if (entity instanceof LivingEntity) {
if (entity instanceof LivingEntity) { // Living entity
LivingEntity le = (LivingEntity) entity;
String maxHealth = String.valueOf(Math.round(getMaxHealth(le)));

Expand Down Expand Up @@ -118,9 +117,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St

}

if (entity instanceof Player) {
// Players

if (entity instanceof Player) { // Players
Player player = (Player) entity;

String playerInfo =
Expand All @@ -141,12 +138,6 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
}

info += playerInfo;
} else {
// Non player entities

String entityInfo = "";
entityInfo = String.format(entityInfo);
// info += entityInfo; // currently there is no extra info for non player entities
}
s(sender, info);
return true;
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/net/serble/estools/Commands/H.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ public boolean onCommand(CommandSender sender, Command command, String label, St

ItemStack is = Give.getItem(args[0], amount);

if (is != null)
setMainHand(p, is);
else
s(sender, "&cItem &6%s&c not found.", args[0]);
if (is != null) {
setMainHand(p, is);
s(sender, "&aGave &6%s", is.getType().name());
} else {
s(sender, "&cItem &6%s&c not found", args[0]);
}

return true;
}
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/net/serble/estools/Commands/Heal.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
} else {
p = getEntity(sender, args[0]);

if (p == null)
return false;
if (p == null) {
return false;
}

s(sender, "&aHealed &6%s", getEntityName(p));
}
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/net/serble/estools/Commands/I.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ public boolean onCommand(CommandSender sender, Command command, String label, St

ItemStack is = Give.getItem(args[0], amount);

if (is != null)
p.getInventory().addItem(is);
else
s(sender, "&cItem &6%s&c not found.", args[0]);
if (is != null) {
p.getInventory().addItem(is);
s(sender, "&aGave &6%s", is.getType().name());
} else {
s(sender, "&cItem &6%s&c not found", args[0]);
}

return true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/serble/estools/Commands/Infinite.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ public boolean onCommand(CommandSender sender, Command command, String label, St

if (!currentPlayers.contains(pu)) {
currentPlayers.add(pu);
s(sender, "&aYou now have infinite blocks!");
s(sender, "&aYou now have &6infinite &ablocks!");
} else {
currentPlayers.remove(pu);
s(sender, "&aYou no longer have infinite blocks");
s(sender, "&aYou now have &6finite &ablocks!");
}

return true;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/serble/estools/Commands/Invsee.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St

((Player) sender).openInventory(target.getInventory());

s(sender, "&aOpened %s's Inventory", target.getName());
s(sender, "&aOpened &6%s's &aInventory", target.getName());
return true;
}

Expand Down
1 change: 0 additions & 1 deletion src/main/java/net/serble/estools/Commands/Music.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
name = String.valueOf(name.charAt(0)).toUpperCase() + name.substring(1);

s(sender, "&aNow Playing: &6%s", name);

return true;
}

Expand Down
1 change: 1 addition & 0 deletions src/main/java/net/serble/estools/Commands/Night.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
return true;

((Player)sender).getWorld().setTime(13000);
s(sender, "&aSet time to &6night");
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public static void cmd(CommandSender sender, ItemStack pp) {
Player p = (Player)sender;

p.getInventory().addItem(pp);
s(sender, "&aThere you go!");
}

public static void init() {
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/net/serble/estools/Commands/SetHealth.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ public boolean onCommand(CommandSender sender, Command command, String label, St

setHealth(p, health);

if (args.length > 1)
s(sender, "&aSet health for &6%s&a to &6%s", getEntityName(p), String.valueOf(health));
else
s(sender, "&aSet health to &6%s", String.valueOf(health));
if (args.length > 1) {
s(sender, "&aSet health for &6%s&a to &6%s", getEntityName(p), String.valueOf(health));
} else {
s(sender, "&aSet health to &6%s", String.valueOf(health));
}
}
else
s(sender, "&cCannot set health to less than 0");
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/serble/estools/Commands/SetStack.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
}

getMainHand(((Player)sender)).setAmount(amount);


s(sender, "&aSet stack size to &6%d", amount);
return true;
}

Expand Down
3 changes: 1 addition & 2 deletions src/main/java/net/serble/estools/Commands/Smite.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St

}

if (args.length > 0)
s(sender, "&aBAM!");
s(sender, "&aBAM!");
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/serble/estools/Commands/Sudo.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
com = new StringBuilder(com.toString().trim());

Bukkit.dispatchCommand(p, com.toString());

s(sender, "&aExecuted command &6%s&a as &6%s", com.toString(), p.getName());
return true;
}

Expand Down
1 change: 1 addition & 0 deletions src/main/java/net/serble/estools/Commands/Suicide.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
LivingEntity p = (LivingEntity) sender;

setHealth(p, 0);
s(sender, "&aRest in peace");
return true;
}

Expand Down
1 change: 1 addition & 0 deletions src/main/java/net/serble/estools/Commands/Sun.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
return true;

((Player)sender).getWorld().setTime(1000);
s(sender, "&aSet time to &6day");
return true;
}

Expand Down
6 changes: 4 additions & 2 deletions src/main/java/net/serble/estools/Commands/Teleport/TPAll.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package net.serble.estools.Commands.Teleport;

import net.serble.estools.EntityCommand;
import net.serble.estools.Main;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.LivingEntity;
Expand All @@ -22,8 +20,12 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
}

for (LivingEntity t : getOnlinePlayers()) {
assert p != null;
t.teleport(p);
}

assert p != null;
s(sender, "&aTeleported all players to &6%s", getEntityName(p));
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
if (t != null)
t.teleport(p);
}

s(sender, "&aTeleported &6%s&a to &6%s", argsToString(args, 0), getEntityName(p));
return true;
}
}
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
main: net.serble.estools.Main
name: EsTools
description: Simple highly compatible general purpose plugin.
version: 3.3
version: '${project.version}'
softdepend: [Vault]
authors: [Calcilator, CoPokBl]
api-version: 1.13
Expand Down

0 comments on commit c825f3c

Please sign in to comment.