sendMessage string and int

Discussion in 'Plugin Development' started by Filiusthefirst, Oct 31, 2018.

Thread Status:
Not open for further replies.
  1. Offline

    Filiusthefirst

    Hello,
    i have a problem my plan is that in the Chat from Minecraft is writen:
    [Filmtitel,Date,Szene...,Take]

    in Eclipse it would look like:

    p.sendMessage("[Filmtitel,Date,Szene"); p.sendMessage("for exapmle 3") //it ist a int as a string; p.sendMessage(",Take]");

    did anyone knows what i must write that all this is in one line in the minecraft Chat?
     
  2. Offline

    timtower Administrator Administrator Moderator

    @Filiusthefirst Make a string variable.
    Fill the variable.
    Send the variable.
     
  3. Offline

    Filiusthefirst

    @timtower it dosen´t works.
    when i will create the strin variable:

    String szene = "Hello", +s, "Bey";

    it says only error. s is a variable.

    pleas help me
     
  4. Offline

    timtower Administrator Administrator Moderator

    @Filiusthefirst Because that is not valid Java.
    Those comma's shouldn't be there. I don't know what language you got it from though.
     
  5. Offline

    Filiusthefirst

    @timtower
    Do you know hi can i make it that when the Player write in the Chat /cb (Variable) for all Players come in the Chat the Variable but only at this command
     
  6. Offline

    timtower Administrator Administrator Moderator

    @Filiusthefirst Get the variable in the onCommand, then broadcast the variable.
     
  7. Offline

    Filiusthefirst

    @timtower
    do you know what is wrong?
    Code:
    package me.oli.info;
    
    import java.text.SimpleDateFormat;
    import java.util.Date;
    
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class Plugin extends JavaPlugin {
      
        @Override
        public void onEnable() {
            System.out.println("[Filmklappe] Plugin erfolgreich aktiviert!");
        }
      
        @Override
        public void onDisable() {
            System.out.println("[Filmklappe] Plugin erfolgreich deaktiviert!");
        }
      
        public boolean onCommand(CommandSender sender, Command cmd, String cmdlabel, String[] args) {
            SimpleDateFormat date = new SimpleDateFormat("dd.MM.yyyy");
            String original = date.format(new Date());
            Player p =(Player) sender;
            int s,t;
            s=0;
            t=0;
          
            if(cmd.getName().equalsIgnoreCase("sr")) {
            s=1;
            String szene = String.valueOf(s);
            String take = String.valueOf(t);
            p.sendMessage("[filmtitel|" + original + "|Szene" + szene + "|Take" + take + "|");
              
            }
          
          
            return false;
        }
    
      
    }
    that is the Code
    that is Plugin.yml
    Code:
    name: Filmklappe
    version: 2.0
    author: Oli
    main: me.filiusthefirst.filmklappe.Plugin
    commands:
      sr:
      description: Setzt die Szenen zurueck auf die erste.
      usage: </command>
    ans that is the error Code on the Server
    [12:46:38 ERROR]: Could not load 'plugins\Filmklappe v2.0.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
    at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:150) ~[craftbukkit.jar:git-Bukkit-e60fc34]
    at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:133) [craftbukkit.jar:git-Bukkit-e60fc34]
    at org.bukkit.craftbukkit.v1_12_R1.CraftServer.loadPlugins(CraftServer.java:303) [craftbukkit.jar:git-Bukkit-e60fc34]
    at net.minecraft.server.v1_12_R1.DedicatedServer.init(DedicatedServer.java:188) [craftbukkit.jar:git-Bukkit-e60fc34]
    at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:522) [craftbukkit.jar:git-Bukkit-e60fc34]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_191]
    Caused by: java.io.FileNotFoundException: Jar does not contain plugin.yml
    ... 6 more
     
  8. Offline

    timtower Administrator Administrator Moderator

  9. Offline

    Filiusthefirst

    @timtower and now what schould i do sry i don´t can understand english well what ist lowercase?
     
  10. Offline

    timtower Administrator Administrator Moderator

  11. Offline

    Filiusthefirst

    @timtower jea sry i only Wort at here wrong in the file it ist right
     
  12. Offline

    timtower Administrator Administrator Moderator

    @Filiusthefirst Please translate the entire message, a big piece is still in German.
     
  13. Offline

    Filiusthefirst

    Code:
    package me.oli.info;
    
    import java.text.SimpleDateFormat;
    import java.util.Date;
    
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class Plugin extends JavaPlugin {
    
        @Override
        public void onEnable() {
            System.out.println("[Clipboard] Plugin is online!");
        }
    
        @Override
        public void onDisable() {
            System.out.println("[Clipbord] Plugin os offline!");
        }
    
        public boolean onCommand(CommandSender sender, Command cmd, String cmdlabel, String[] args) {
            SimpleDateFormat date = new SimpleDateFormat("dd.MM.yyyy");
            String original = date.format(new Date());
            Player p =(Player) sender;
            int s,t;
            s=0;
            t=0;
        
            if(cmd.getName().equalsIgnoreCase("sr")) {
            s=1;
            String szene = String.valueOf(s);
            String take = String.valueOf(t);
            p.sendMessage("[filmtitel|" + original + "|szene" + szene + "|take" + take + "|");
            
            }
        
        
            return false;
        }
    
    
    }
    Code:
    name: Clipbord
    version: 2.0
    author: Oli
    main: me.filiusthefirst.filmklappe.Plugin
    commands:
      sr:
      description: set the Szene back to Szene 1
      usage: </command>
    @timtower now it must be everything in english

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
  14. Offline

    timtower Administrator Administrator Moderator

    @Filiusthefirst I wasn't talking about the code, I was talking about this:
     
  15. Offline

    Filiusthefirst

    @timtower

    ok xD that was:
    sry i only wrote it here in the Internet wrong in eclipse the Name of the file is plugin.yml
     
  16. Offline

    timtower Administrator Administrator Moderator

  17. Offline

    Filiusthefirst

    @timtower

    jes the Plugin.yml is in the .jar file
     
  18. Offline

    timtower Administrator Administrator Moderator

    @Filiusthefirst Again, plugin.yml, not Plugin.yml
    Please post a screenshot.
     
  19. Offline

    Filiusthefirst

    my fault sry the Computer write it in big letters from on here is the screenshot:
     

    Attached Files:

  20. Offline

    timtower Administrator Administrator Moderator

    @Filiusthefirst The plugin.yml needs to be in the begin of the jar.
    So when using eclipse: put it in the project folder, not in the source folder.
     
  21. Offline

    Filiusthefirst

    @timtower
    ok now this Comes in the consol
    Code:
    [13:42:25 ERROR]: Could not load 'plugins\Filmklappe v2.0.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: Cannot find main class `me.filiusthefirst.filmklappe.Plugin'
            at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:56) ~[craftbukkit.jar:git-Bukkit-e60fc34]
            at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:127) ~[craftbukkit.jar:git-Bukkit-e60fc34]
            at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:326) ~[craftbukkit.jar:git-Bukkit-e60fc34]
            at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:248) [craftbukkit.jar:git-Bukkit-e60fc34]
            at org.bukkit.craftbukkit.v1_12_R1.CraftServer.loadPlugins(CraftServer.java:303) [craftbukkit.jar:git-Bukkit-e60fc34]
            at net.minecraft.server.v1_12_R1.DedicatedServer.init(DedicatedServer.java:188) [craftbukkit.jar:git-Bukkit-e60fc34]
            at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:522) [craftbukkit.jar:git-Bukkit-e60fc34]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_191]
    Caused by: java.lang.ClassNotFoundException: me.filiusthefirst.filmklappe.Plugin
            at java.net.URLClassLoader.findClass(Unknown Source) ~[?:1.8.0_191]
            at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:128) ~[craftbukkit.jar:git-Bukkit-e60fc34]
            at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:76) ~[craftbukkit.jar:git-Bukkit-e60fc34]
            at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_191]
            at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_191]
            at java.lang.Class.forName0(Native Method) ~[?:1.8.0_191]
            at java.lang.Class.forName(Unknown Source) ~[?:1.8.0_191]
            at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:54) ~[craftbukkit.jar:git-Bukkit-e60fc34]
            ... 7 more
    and that is the new screenshot :
     

    Attached Files:

  22. Offline

    timtower Administrator Administrator Moderator

    @Filiusthefirst Try alt+printscreen, then you take just the window instead of the entire screen.
    Your code is in package me.oli.info, your plugin.yml looks for me.filiusthefirst.filmklappe.Plugin
    Those need to be the same.
     
  23. Offline

    Filiusthefirst

    @timtower but you have said that the plugin.yml must be in the projekt foulder. must i take my Code out of the package?
     
  24. Offline

    timtower Administrator Administrator Moderator

    No.
    You need to change the main field in the plugin.yml so it points to your actual main class.
     
  25. Offline

    Filiusthefirst

    @timtower
    it works thak you that you had so mutch time for me your are the best moderator i ever see. Thank you so mutch and by.
     
Thread Status:
Not open for further replies.

Share This Page